Using a transaction to insert into two typed dataset tables

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Hi All,

I'm hoping someone could advise me on how to make the following two
operations atomic.

I have a Places table and a PlaceBoundaryPoints table.

When I create a "Place" I need to add a Place row and a number of
PlaceBoundaryPoints (e.g. a place is made up of several boundary points,
which are stored in a seperate table)

I would like the insertion to be atomic.

I have a strongly typed dataset that contains the two datatables - each
has been configured with full select/insert/update/delete commands

Can anyone advise me on how I can share a transaction between the two
operations so that I can commit or rollback as necessary?

Many thanks to anyone who can help

Kindet Regards

Simon
 
Simon,

Look at the TransactionScope class in the System.Transactions namespace.
You can create the scope, then call update on the adapters for the two
tables, and then call the Commit method to commit the transaction.
 
Back
Top