dotConnect for PostgreSQL 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.
    PostgreSqlCommand1.Connection=PostgreSqlConnection1;
    using (TransactionScope transScope = new TransactionScope()) {
     PostgreSqlConnection1.Open();
     PostgreSqlCommand1.ExecuteNonQuery();
     transScope.Complete();
    }
    PostgreSqlConnection1.Close();
    
    - or -
    
    PostgreSqlCommand1.Connection=PostgreSqlConnection1;
    PostgreSqlConnection1.Open();
    using (TransactionScope transScope = new TransactionScope()) {
     PostgreSqlConnection1.EnlistTransaction(Transaction.Current);
     PostgreSqlCommand1.ExecuteNonQuery();
     transScope.Complete();
    }
    PostgreSqlConnection1.Close();
    
    - or -
    
    CommittableTransaction cmtTx = new CommittableTransaction();
    PostgreSqlConnection1.Open();
    PostgreSqlConnection1.EnlistTransaction(cmtTx);
    PostgreSqlCommand1.ExecuteNonQuery();
    PostgreSqlConnection1.Close();
    Me.PostgreSqlCommand1.Connection = Me.PostgreSqlConnection1
    Using transScope = New Transactions.TransactionScope
      Me.PostgreSqlConnection1.Open()
      Me.PostgreSqlCommand1.ExecuteNonQuery()
      transScope.Complete()
    End Using
    Me.PostgreSqlConnection1.Close()
    
    - or -
    
    Me.PostgreSqlCommand1.Connection = Me.PostgreSqlConnection1
    Me.PostgreSqlConnection1.Open()
    Using transScope = New Transactions.TransactionScope
      Me.PostgreSqlConnection1.EnlistTransaction(Transactions.Transaction.Current)
      Me.PostgreSqlCommand1.ExecuteNonQuery()
      transScope.Complete()
    End Using
    Me.PostgreSqlConnection1.Close()
    
    - or -
    
    Dim cmtTx As New Transactions.CommittableTransaction
    Me.PostgreSqlConnection1.Open()
    Me.PostgreSqlConnection1.EnlistTransaction(cmtTx)
    Me.PostgreSqlCommand1.ExecuteNonQuery()
    Me.PostgreSqlConnection1.Close()
    See Also