dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlCommand Class / UnpreparedExecute Property
Example

In This Topic
    UnpreparedExecute Property (PgSqlCommand)
    In This Topic
    Determines if 'simple query' sub-protocol is applied for executing SQL statements without preparing on server side.
    Syntax
    'Declaration
     
    Public Property UnpreparedExecute As Boolean
    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.
    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";
    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

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also