dotConnect for Zoho Books 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.
ZohoBooksCommand1.Connection=ZohoBooksConnection1;
using (TransactionScope transScope = new TransactionScope()) {
 ZohoBooksConnection1.Open();
 ZohoBooksCommand1.ExecuteNonQuery();
 transScope.Complete();
}
ZohoBooksConnection1.Close();

- or -

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

- or -

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

- or -

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

- or -

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