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
UpdateRowSource.FirstReturnedRecord
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?
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?