Transaction with oledbCommandBuilder

  • Thread starter Thread starter Devdatta
  • Start date Start date
D

Devdatta

Hello,
I want to give transaction support with Commands
generated by OledbCommandBuilder, can anybody tell me how to do that.

Regards,
Devdatta
 
Right before you fire update, begin a transaction.

Dim tra as SqlTransaction

tra = myConnection.BeginTransaction


then, fire your update or whatever,

Make sure it's wrapped in a Try catch block. The next line after update
should be Transaction.Commit.

In your exception block, use Transaction.Rollback.

HTH

Bill
 
The problem here is that there is a known bug with the CommandBuilder and
transactions, if you try to deriveparameters on a command while a
transaction is active you will get the error that indicates that you need to
associate the transaction to the command.

The workarround is to open a fresh connection that you can assign to the
command, derive parameters using the new connection, and then associate the
command to the connection that is using the transaction that you want to run
under.

Sorry about that,
 
Back
Top