views:

29

answers:

1

Hi,

I'm wondering if it's possible to create my own services that I can use in an ADO transaction. For example, I'd like to

  1. make some database updates in an ADO transaction
  2. make some arbitrary updates in some arbitrary service that I create
  3. either commit or rollback the transaction, and have my arbitrary service understand that the transaction has been either committed or rolled back, and take the appropriate action

Basically, I'd like to implement the Commit() and Rollback() methods myself, but I can't figure out how to 'join' that to an ADO transaction.

Cheers, thanks a lot.

A: 

You use .Net transactions, not ADO transactions. ADO is aware of the System.Transactions infrastructure and while under a TransactionScope it will enlist all the ADO operations into that system transaction.

To add your own custom operation you must create a new Resource Manager, a class that implements IEnlistmentNotifications. Building a RM is not trivial and you must understand concepts like Durable enlistment vs. Volatile enlistment, Two Phase Commit, Promotable Single Phase Enlistment and so on and so forth.

Good luck.

Remus Rusanu
Perfect - thanks!
Alex

related questions