Transactions across connections.

  • Thread starter Thread starter Nerd
  • Start date Start date
N

Nerd

I have 3 function in my component . all 3 something are like this

Open Connection
Issue SQL statements(insert /update/delete)
Close connection


Now I have an application that uses these 3 functions in various parts.
I want this application to manage transaction.

When doing operation1 this is what I need

Start Transaction
Call Function1
Call Function2
Call Function3
Commit transaction

When doing operation2 this is what I need
Start Transaction
Call Function1
Call Function3
Commit transaction

So in short I want to manage transactions across connection to the same
DB.

Is this possible with ADO.Net or Data Access Application Blocks? Or
Should I go for System.Transaction(have not read that yet).

Thanks
BCR
 
You cannot make transactions with more than one connection. You can do
the following.

Open ConnectionA
Start Transaction
Call Function1 (using ConnectionA)
Call Function2 (using ConnectionA)
Call Function3 (using ConnectionA)
Commit transaction
Close Connection

You can try to create 3 transactions (with 3 conections) and commit
then only if the 3 Functions success. Example:

Open ConnectionA
Open ConnectionB
Open ConnectionC
Start TransactionA
Start TransactionB
Start TransactionC
Call Function1 (using ConnectionA)
Call Function2 (using ConnectionB)
Call Function3 (using ConnectionC)
Commit transactions A, B, C if success, else rollback.
Close Connections A, B, C
 
Back
Top