Hi,
I using command builder to generate my insert, update and
delete statements..som ething like,
data_adapter = New SqlClient.SqlDa taAdapter(SQL,
ActiveConnectio n)
command_builder = New SqlClient.SqlCo mmandBuilder
(data_adapter)
After filling a data grid and making changes to the data,
I want to call the adapter.Update method in a database
transaction, so that I can rollback the transaction, if
the update fails..
This is my code, for that..
*************** *************** *********
Dim trans As SqlClient.SqlTr ansaction
trans = adp.SelectComma nd.Connection.B eginTransaction
adp.Update(ds)
***************
In the adp.Update(ds) line, I get the exception,
"Execute requires the command to have a transaction object
when the connection assigned to the command is in a
pending local transaction. The Transaction property of
the command has not been initialized."
What am I doing wrong..?
Please help with a code snippet.
Regards,
Swami
I using command builder to generate my insert, update and
delete statements..som ething like,
data_adapter = New SqlClient.SqlDa taAdapter(SQL,
ActiveConnectio n)
command_builder = New SqlClient.SqlCo mmandBuilder
(data_adapter)
After filling a data grid and making changes to the data,
I want to call the adapter.Update method in a database
transaction, so that I can rollback the transaction, if
the update fails..
This is my code, for that..
*************** *************** *********
Dim trans As SqlClient.SqlTr ansaction
trans = adp.SelectComma nd.Connection.B eginTransaction
adp.Update(ds)
***************
In the adp.Update(ds) line, I get the exception,
"Execute requires the command to have a transaction object
when the connection assigned to the command is in a
pending local transaction. The Transaction property of
the command has not been initialized."
What am I doing wrong..?
Please help with a code snippet.
Regards,
Swami
Comment