update DataSet - transaction

  • Thread starter Thread starter TheMaxx
  • Start date Start date
T

TheMaxx

I have two tables in dataset, and appropriate TableAdapters.

How can i update both tables, but in transaction?

I other words:

THIS:
MyDSTableAdapters.Table1TableAdapter a1 = new ...
MyDSTableAdapters.Table1TableAdapter a2 = new ...

a1.Update(dt1);
a2.Update(dt2);

but where to put transaction ?

P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
ServerExplorer drag n' drop
 
You can just declare and instantiate it right before the Update statements,
Try/catch the Updates, Rollback on exception.
 
Cor & Ryan, thanx for answers, but i think we are missing a point.
I am well aware of SqlTransaction object, but how to set the same
transaction for each TableAdapter?

p.s. this is 2.0, i think TableAdapters were not provided in VS 2003
 
I think you finally got me!
This is an answer i was looking for.
But it just feels like a walkaround instead a straight forward, 'by the book
(MSDN)' stuff.
It's hard to belive that Microsoft did not provide something simpler for a
common functionality.

Why introducing TableAdapters when transaction is not provided for them?
Also i can hardy belive that TableAdapters do not have a base class (or
interface) so it's making it hard to program generic solution for them.
 
Back
Top