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

In This Topic
    EnlistTransaction Method
    In This Topic
    Enlists in the specified transaction.
    Syntax
    'Declaration
     
    Public Overrides Sub EnlistTransaction( _
       ByVal transaction As Transaction _
    ) 
    public override void EnlistTransaction( 
       Transaction 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()
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also