G
Guest
Hi,
I am porting an ADO.NET 1.1 project to version 2.0 and trying to take
advantage of the dataAdapter's UpdateBatchSize property. When I set this to
0 and change my updatedRowSource to either NONE or OUTPUT PARAMS, I get the
following error when trying to update more than one row.
5/10/2006 12:52:18 - Exception occurred ---> Description:
ExceptionHandling.CustomException: The ConnectionString property has not been
initialized. ---> System.InvalidOperationException: The ConnectionString
property 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)
My update method is as follows. I initialize the data adapter's update
related sql command objects' connections at run-time. (I am not using
'USING' as I want to catch exceptions)
Private Sub DoUpdate()
Dim cn As New SqlConnection(strConn)
Me.dataAdapter1UpdateCommand.Connection = cn
Me.dataAdapter1DeleteCommand.Connection = cn
Me.dataAdapter1InsertCommand.Connection = cn
Try
Me.dataAdapter1.Update(Me.Ds.dtMyTable)
Catch ex As Exception
LogExceptions(Me.Name, "DoUpdate", ex)
MessageBox.Show(strChgError, strSrvrError, MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
cn.Dispose()
End Try
End Sub
Can anyone tell me why this happens and how to fix it. I can correct the
problem by setting the updateBatchSize to 1, and the problem does not occur
when only one row is being updated. I am connecting to SQL Server 2000 SP4.
Thanks.
I am porting an ADO.NET 1.1 project to version 2.0 and trying to take
advantage of the dataAdapter's UpdateBatchSize property. When I set this to
0 and change my updatedRowSource to either NONE or OUTPUT PARAMS, I get the
following error when trying to update more than one row.
5/10/2006 12:52:18 - Exception occurred ---> Description:
ExceptionHandling.CustomException: The ConnectionString property has not been
initialized. ---> System.InvalidOperationException: The ConnectionString
property 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)
My update method is as follows. I initialize the data adapter's update
related sql command objects' connections at run-time. (I am not using
'USING' as I want to catch exceptions)
Private Sub DoUpdate()
Dim cn As New SqlConnection(strConn)
Me.dataAdapter1UpdateCommand.Connection = cn
Me.dataAdapter1DeleteCommand.Connection = cn
Me.dataAdapter1InsertCommand.Connection = cn
Try
Me.dataAdapter1.Update(Me.Ds.dtMyTable)
Catch ex As Exception
LogExceptions(Me.Name, "DoUpdate", ex)
MessageBox.Show(strChgError, strSrvrError, MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
cn.Dispose()
End Try
End Sub
Can anyone tell me why this happens and how to fix it. I can correct the
problem by setting the updateBatchSize to 1, and the problem does not occur
when only one row is being updated. I am connecting to SQL Server 2000 SP4.
Thanks.