Results 1 to 3 of 3

Thread: Transaction state

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    Transaction state

    Hi,

    Is it possible to find the state of a transaction, whether it is open or not.

    In my code the BeginTrans is in conditional statements, I don't want my error code to execute the RollBackTrans if the BeginTrans has not been executed.

    Thanks all.

  2. #2
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    you could try something like this:

    VB Code:
    1. Dim WithEvents cn As ADODB.Connection
    2. Dim bTransactionOpen As Boolean
    3.  
    4. Private Sub cn_BeginTransComplete(ByVal TransactionLevel As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
    5.     bTransactionOpen = True
    6. End Sub
    7.  
    8. Private Sub cn_CommitTransComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
    9.     bTransactionOpen = False
    10. End Sub
    11.  
    12. Private Sub cn_RollbackTransComplete(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
    13.     bTransactionOpen = False
    14. End Sub

    and then just test the boolean variable to see if it's open or not.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Thanks tr0n,

    I am actually using a dataEnvironment object, rather than a variable connection.

    Its certainly put me on the right track.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width