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.
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"
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