transactions with dataadapter update?

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!
 
T

TJO

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...
 
M

Miha Markic

Hi Mathew,

IDbConnection (Connection object) has a method BeginTransaction that will
return you a valid transaction (IDbTransaction).
IDbTransaction has Commit and Rollback methods.
 
G

Guest

Great! Thanks! I was trying to use
mydataadapter.updatecommand.transaction = mytransaction.

works like a charm!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top