dotConnect for SQLite 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.
SQLiteCommand1.Connection=SQLiteConnection1;
using (TransactionScope transScope = new TransactionScope()) {
 SQLiteConnection1.Open();
 SQLiteCommand1.ExecuteNonQuery();
 transScope.Complete();
}
SQLiteConnection1.Close();

- or -

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

- or -

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

- or -

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

- or -

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