Create a Transactional Web Method


You want to execute all the actions in a Web method within the context of a single COM+ transaction so that they all either fail or succeed as a unit.


Enable an automatic transaction using the TransactionOption property of the WebMethod attribute.


.NET Web services include support for automatic transactions that can be enabled on a per-method basis. When enabled, any data source that supports COM+ transactions (which includes most databases) is automatically enlisted in the current transaction when it’s used in your code. The transaction is automatically committed when the Web method completes. The transaction is rolled back if any unhandled exception occurs or if you explicitly call the ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.