Page 1 of 1

UpdateRowSource.FirstReturnedRecord

Posted: Tue 30 Jan 2007 11:26
by gelny
Hi,

i have in code for MSSQL :

DbDataAdapter da = DataFactory.CreateDataAdapter("Select * from ServiceConfig", connection);
DataFactory.CreateCommandBuilder(da);
((SqlDataAdapter) da).InsertCommand.CommandText += "; Select * from ServiceConfig WHERE ID=@@IDENTITY";
((SqlDataAdapter) da).InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
da.Fill(dataSet, "ServiceConfig");

now i rewrite application to PostGre and when i call Update on DataSet from code :

DbDataAdapter da = DataFactory.CreateDataAdapter("Select * from network", connection);
DataFactory.CreateCommandBuilder(da);
((PgSqlDataAdapter)da).InsertCommand.CommandText += "; Select * from network WHERE id=currval('network_id_seq')";
((PgSqlDataAdapter)da).InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
da.Fill(dataSet, "network");

show me error :

CoreLab.PostgreSql.PgSqlException: cannot insert multiple commands into a prepared statement
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)

What is bad??????

Gelny

Posted: Tue 30 Jan 2007 12:16
by Alexey
Protocol 3.0 doesn't support multiple query execution.
To enable this, set Protocol=2.0 in your connection string.

Posted: Fri 02 Feb 2007 07:37
by gelny
Thanks,

it works, but now it is showing error:

CoreLab.PostgreSql.PgSqlException: ERROR: currval of sequence "network_id_seq" is not yet defined in this session

at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)


Why?

Posted: Mon 05 Feb 2007 15:02
by Alexey
Please send us small test project if possible to reproduce the problem.
Include the definition of your own database objects.
Use e-mail address provided in the Readme file.
Do not use third party components.

Posted: Fri 09 Feb 2007 16:11
by Alexey
We have fixed the problem.
Look forward to the next build.

Posted: Mon 19 Feb 2007 14:49
by Alexey
After deeper investigation we found out that the problem is actually in your code. When you are trying to perform a SELECT the current value of "network_id_seq" sequence is not defined yet. You can check this with PgAdmin. For more information please consult PostgreSQL documentation.