- transaction
- A reference to an existing System.EnterpriseServices.ITransaction in which to enlist.
New in ADO.NET 2.0 is support for using the System.Data.Common.DbConnection.EnlistTransaction(System.Transactions.ITransaction) method to enlist in a distributed transaction. Because it enlists a connection in a System.Transactions.Transaction instance, EnlistTransaction takes advantage of functionality available in the System.Transactions namespace for managing distributed transactions, making it preferable to EnlistDistributedTransaction for this purpose. For more information, see Performing a Distributed Transaction.
You can continue to enlist in an existing distributed transaction using the OleDbConnection.EnlistDistributedTransaction(System.EnterpriseServices.ITransaction) method if auto-enlistment is disabled. Enlisting in an existing distributed transaction makes sure that, if the transaction is committed or rolled back, modifications made by the code at the data source are also committed or rolled back. For more information about distributed transactions, see Performing a Distributed Transaction.
OleDbConnection.EnlistDistributedTransaction(System.EnterpriseServices.ITransaction) returns an exception if the System.Data.OleDb.OleDbConnection has already started a transaction using erload:System.Data.OleDb.OleDbConnection.BeginTransaction. However, if the transaction is a local transaction started at the data source (for example, by explicitly executing the BEGIN TRANSACTION statement using an System.Data.OleDbClient.OleDbCommand object), OleDbConnection.EnlistDistributedTransaction(System.EnterpriseServices.ITransaction) rolls back the local transaction and enlists in the existing distributed transaction as requested. You will not receive notice that the local transaction was rolled back, and are responsible for managing any local transactions not started using erload:System.Data.OleDb.OleDbConnection.BeginTransaction.