transactions with dataadapter update?

  • Thread starter Thread starter Mathew Michuta
  • Start date Start date
M

Mathew Michuta

I have a dataset that i read into a datagrid, and I need
to find a way to update that table using transactions in
case some records update and some don't.

I would rather use the data adapter update so I dont have
to use all those update statements.

Thanks!
 
All you do is set the Select, Insert, Update, Delete commands of the
DataAdapter to a new Transactions. Something like this:

myDataAdapter.SelectCommand.Transaction = myTransaction;
myDataAdapter.SelectCommand.Transaction = myTransaction;
etc...
myTransaction.BeginTran...
myTransaction.Commit...
 
Hi Mathew,

IDbConnection (Connection object) has a method BeginTransaction that will
return you a valid transaction (IDbTransaction).
IDbTransaction has Commit and Rollback methods.
 
Great! Thanks! I was trying to use
mydataadapter.updatecommand.transaction = mytransaction.

works like a charm!
 
Back
Top