dotConnect for PostgreSQL Documentation
UnpreparedExecute Property
See Also  Example support@devart.com
Devart.Data.PostgreSql Namespace > PgSqlCommand Class : UnpreparedExecute Property

Determines if 'simple query' sub-protocol is applied for executing SQL statements without preparing on server side.

Syntax

Visual Basic (Declaration) 
Public Property UnpreparedExecute As Boolean
C# 
public bool UnpreparedExecute {get; set;}

Property Value

true, if unprepared execute mode is used; otherwise false. Default valuse if false.

Remarks

This property is useful when using ProtocolVersion.Ver30. By default all queries are prepared when using ProtocolVersion.Ver30. You should set UnpreparedExecute property to true to avoid preparing. In this case queries will be sent in 'simple query' mode - simple executing queries without preparing them on the server. This is useful when executing multiple queries. PostgreSQL server allows preparing only one query at a time, and it returns error if batch queries were sent.

UnpreparedExecute does not affect anything if ProtocolVersion.Ver20 is used, because this protocol is itself 'simple query' or plain text protocol. SQL statement execution is made without preparing by default.

Example

This sample executes batch of SQL statements using the ProtocolVersion.Ver30. Setting UnpreparedExecute property to true disables server-side preparing of the queries.
C#csharpCopy Code
PgSqlConnection myConnection = new PgSqlConnection("user id=postgres;
        password=postgres;host=localhost;Protocol=ver30;Database=test;schema=test");
myConnection.Open();

PgSqlCommand myComman = new PgSqlCommand();
myComman.Connection = myConnection;
myComman.UnpreparedExecute = true;
myComman.CommandText = "SELECT 1;SELECT 2";
C#Visual BasicCopy Code
Dim myConnection As PgSqlConnection = New PgSqlConnection("user id=postgres;" & _
        "password=postgres;host=localhost;Protocol=ver30;Database=test;schema=test")
myConnection.Open()

Dim myComman As PgSqlCommand = New PgSqlCommand()
myComman.Connection = myConnection
myComman.UnpreparedExecute = True
myComman.CommandText = "SELECT 1;SELECT 2"

Requirements

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also