dotConnect for BigCommerce Documentation
Devart.Common Namespace / DbConnectionBase Class / EnlistTransaction Method
A reference to an existing System.Transactions.Transaction in which to enlist.
Example

EnlistTransaction Method
Enlists in the specified transaction.
Syntax
'Declaration
 
Public Overrides Sub EnlistTransaction( _
   ByVal transaction As Transaction _
) 
 

Parameters

transaction
A reference to an existing System.Transactions.Transaction in which to enlist.
Remarks

Once a connection is explicitly enlisted in a distributed transaction, it cannot be unenlisted or enlisted in another transaction until the first transaction finishes.

Example
These samples demonstrate usage of EnlistTransaction.
BigcommerceCommand1.Connection=BigcommerceConnection1;
using (TransactionScope transScope = new TransactionScope()) {
 BigcommerceConnection1.Open();
 BigcommerceCommand1.ExecuteNonQuery();
 transScope.Complete();
}
BigcommerceConnection1.Close();

- or -

BigcommerceCommand1.Connection=BigcommerceConnection1;
BigcommerceConnection1.Open();
using (TransactionScope transScope = new TransactionScope()) {
 BigcommerceConnection1.EnlistTransaction(Transaction.Current);
 BigcommerceCommand1.ExecuteNonQuery();
 transScope.Complete();
}
BigcommerceConnection1.Close();

- or -

CommittableTransaction cmtTx = new CommittableTransaction();
BigcommerceConnection1.Open();
BigcommerceConnection1.EnlistTransaction(cmtTx);
BigcommerceCommand1.ExecuteNonQuery();
BigcommerceConnection1.Close();
Me.BigcommerceCommand1.Connection = Me.BigcommerceConnection1
Using transScope = New Transactions.TransactionScope
  Me.BigcommerceConnection1.Open()
  Me.BigcommerceCommand1.ExecuteNonQuery()
  transScope.Complete()
End Using
Me.BigcommerceConnection1.Close()

- or -

Me.BigcommerceCommand1.Connection = Me.BigcommerceConnection1
Me.BigcommerceConnection1.Open()
Using transScope = New Transactions.TransactionScope
  Me.BigcommerceConnection1.EnlistTransaction(Transactions.Transaction.Current)
  Me.BigcommerceCommand1.ExecuteNonQuery()
  transScope.Complete()
End Using
Me.BigcommerceConnection1.Close()

- or -

Dim cmtTx As New Transactions.CommittableTransaction
Me.BigcommerceConnection1.Open()
Me.BigcommerceConnection1.EnlistTransaction(cmtTx)
Me.BigcommerceCommand1.ExecuteNonQuery()
Me.BigcommerceConnection1.Close()
See Also