how dotConnect for PostgreSQL work with ibatis.net
how dotConnect for PostgreSQL work with ibatis.net
i use dotConnect for PostgreSQL in ibatis.net
ibatis.net don't use command prepare method default but
dotConnect for PostgreSQL , PgSqlCommand's property UnpreparedExecute is false default.
so when i execute batch sql will throw exception
batch sql like this:
INSERT INTO "Frm_Dept"("DeptName","ParentId")VALUES('dept1',1);
INSERT INTO "Frm_Dept"("DeptName","ParentId")VALUES('dept2',2);
exception:
Devart.Data.PostgreSql.PgSqlException: cannot insert multiple commands into a prepared statement
at Devart.Data.PostgreSql.v.c(r A_0)
at Devart.Data.PostgreSql.r.af()
at Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Devart.Common.DbCommandBase.ExecuteNonQuery()
at IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteNonQuery()
ibatis.net don't use command prepare method default but
dotConnect for PostgreSQL , PgSqlCommand's property UnpreparedExecute is false default.
so when i execute batch sql will throw exception
batch sql like this:
INSERT INTO "Frm_Dept"("DeptName","ParentId")VALUES('dept1',1);
INSERT INTO "Frm_Dept"("DeptName","ParentId")VALUES('dept2',2);
exception:
Devart.Data.PostgreSql.PgSqlException: cannot insert multiple commands into a prepared statement
at Devart.Data.PostgreSql.v.c(r A_0)
at Devart.Data.PostgreSql.r.af()
at Devart.Data.PostgreSql.PgSqlCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Devart.Common.DbCommandBase.ExecuteNonQuery()
at IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteNonQuery()
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
We've released the 4.95.152 build where this functionality is implemented. The new build can be downloaded from
http://www.devart.com/dotconnect/postgr ... nload.html
(the trial version) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/
For more information on improvements and fixes available in the 4.95.152 version, please refer to
http://www.devart.com/forums/viewtopic.php?t=18591
http://www.devart.com/dotconnect/postgr ... nload.html
(the trial version) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/
For more information on improvements and fixes available in the 4.95.152 version, please refer to
http://www.devart.com/forums/viewtopic.php?t=18591
I'm confused ...
Using the following code and build 4.95.152, I still get the "cannot insert multiple commands into a prepared statement" exception.
Is this supposed to work now?
Using the following code and build 4.95.152, I still get the "cannot insert multiple commands into a prepared statement" exception.
Is this supposed to work now?
Code: Select all
DbProviderFactory providerFactory = DbProviderFactories.GetFactory("Devart.Data.PostgreSql");
DbConnection connection = providerFactory.CreateConnection();
connection.ConnectionString = "Host=localhost;Database=test;User Id=me;Unprepared Execute=true;Unicode=true;Password=secret";
connection.Open();
DbCommand command = connection.CreateCommand();
command.CommandText = @"INSERT INTO test_table(intval,strval) VALUES(1,'test1');
INSERT INTO test_table(intval,strval) VALUES(2,'test2');";
command.ExecuteNonQuery();
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
The PgSqlCommand class is designed for executing single SQL commands only. For multiple commands execution, please use the PgSqlScript component instead.
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Sorry for the previous post, the multiple commands execution should work with the 'Unprepared Execute' parameter set to true. We've reproduced the problem in case of creating the connection via DbProviderFactory. We will investigate it and inform you about the results. At the moment, a possible workaround is to create the PgSqlConnection object directly:
Code: Select all
PgSqlConnection connection = new PgSqlConnection();
connection.ConnectionString = connectionString;
connection.Open();
DbCommand command = connection.CreateCommand();
command.CommandText = @"INSERT INTO test_table(intval,strval) VALUES(1,'test1');
INSERT INTO test_table(intval,strval) VALUES(2,'test2');";
command.ExecuteNonQuery();