dotConnect for QuickBooks Online 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 Devart.Data.QuickBooks.QuickBooksConnection.EnlistTransaction.
    quickBooksCommand1.Connection=quickBooksConnection1;
    using (TransactionScope transScope = new TransactionScope()) {
     quickBooksConnection1.Open();
     quickBooksCommand1.ExecuteNonQuery();
     transScope.Complete();
    }
    quickBooksConnection1.Close();
    
    - or -
    
    quickBooksCommand1.Connection=quickBooksConnection1;
    quickBooksConnection1.Open();
    using (TransactionScope transScope = new TransactionScope()) {
     quickBooksConnection1.EnlistTransaction(Transaction.Current);
     quickBooksCommand1.ExecuteNonQuery();
     transScope.Complete();
    }
    quickBooksConnection1.Close();
    
    - or -
    
    CommittableTransaction cmtTx = new CommittableTransaction();
    quickBooksConnection1.Open();
    quickBooksConnection1.EnlistTransaction(cmtTx);
    quickBooksCommand1.ExecuteNonQuery();
    quickBooksConnection1.Close();
    Me.quickBooksCommand1.Connection = Me.quickBooksConnection1
    Using transScope = New Transactions.TransactionScope
      Me.quickBooksConnection1.Open()
      Me.quickBooksCommand1.ExecuteNonQuery()
      transScope.Complete()
    End Using
    Me.quickBooksConnection1.Close()
    
    - or -
    
    Me.quickBooksCommand1.Connection = Me.quickBooksConnection1
    Me.quickBooksConnection1.Open()
    Using transScope = New Transactions.TransactionScope
      Me.quickBooksConnection1.EnlistTransaction(Transactions.Transaction.Current)
      Me.quickBooksCommand1.ExecuteNonQuery()
      transScope.Complete()
    End Using
    Me.quickBooksConnection1.Close()
    
    - or -
    
    Dim cmtTx As New Transactions.CommittableTransaction
    Me.quickBooksConnection1.Open()
    Me.quickBooksConnection1.EnlistTransaction(cmtTx)
    Me.quickBooksCommand1.ExecuteNonQuery()
    Me.quickBooksConnection1.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