S
sahon
Hello.
I tried to use new UpdateBatchSize of SqlDataAdapter with SqlTransaction,
unfortunately every time I have exception during Update of SqlDataAdapter:
System.InvalidOperationException: ExecuteNonQuery requires the command to
have a transaction when the connection assigned to the command is in a
pending local transaction. The Transaction property of the command has not
been initialized.
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)
Insert SQL Command of DataAdapter is:
INSERT INTO [MyTable] ([sValue]) VALUES (@sValue);SELECT
@iID=IDENT_CURRENT('MyTable')
@iID is output parameter that mapped to iID column of DataTable
and UpdatedRowSource of Insert Command =
System.Data.UpdateRowSource.OutputParameters;
In the table there are only New records, so Update and Delete command will
not work.
With default UpdateBatchSize =1 everything works.
Could you advise me something to make it working or is it a bug?
Regards, Sahon
I tried to use new UpdateBatchSize of SqlDataAdapter with SqlTransaction,
unfortunately every time I have exception during Update of SqlDataAdapter:
System.InvalidOperationException: ExecuteNonQuery requires the command to
have a transaction when the connection assigned to the command is in a
pending local transaction. The Transaction property of the command has not
been initialized.
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)
Insert SQL Command of DataAdapter is:
INSERT INTO [MyTable] ([sValue]) VALUES (@sValue);SELECT
@iID=IDENT_CURRENT('MyTable')
@iID is output parameter that mapped to iID column of DataTable
and UpdatedRowSource of Insert Command =
System.Data.UpdateRowSource.OutputParameters;
In the table there are only New records, so Update and Delete command will
not work.
With default UpdateBatchSize =1 everything works.
Could you advise me something to make it working or is it a bug?
Regards, Sahon