views:

392

answers:

1

Hi, I need to ensure 2 calls are enlisted in a transaction

Sub InsertOrder(order)

...insert order header SQL

....insert order items SQL (LOOP)

End Sub

I am aware I can accomplish this via a transaction scope, however, isn't there a "Attribute" available for this?

Transaction.Scope()>_
Public Sub InsertOrder(order)

End Sub
+1  A: 

There is a .NET Attribute that can be used for Transactions. However it is intended more for distributed transactions across multiple data sources that require a 2-phase commit. The attributes are part of the 'Enterprise services transaction' system.

The 'classic' way to manage a SQL transaction was by calling the BeginTransaction(), Commit() and Rollback() methods of the SqlConnection object.

There is also the System.Transactions model which is based on the 'using' statement and a TransactionScope object, which you mentioned.

See this link for a clear summary of the different options.

codeulike