Transactions in ADO.NET

Until now, you have used only T-SQL to manage transactions, but transactions can also be managed directly through ADO.NET. Transactions in ADO.NET are managed through the SQLTransaction class, which can be found in the System.Data.SqlClient namespace. For every transaction, an isolation level can be provided through the IsolationLevel Enumerators namespace.

The following example shows how a transaction can be defined through ADO.NET. The transaction is rolled back on any error and committed when no error occurs. This code is included in the sample files as Chapter10.sln. To run the sample, build and execute the solution in Visual Studio, then make sure the Output window is visible in Visual Studio while you click the ...

Get Microsoft® SQL Server™ 2005: Applied Techniques Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.