Results 1 to 2 of 2

Thread: BeginTrans/RollBack/CommitTrans

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    4

    Question

    Whats the best way to implement a (ADO) Rollback
    in case there was an unexpected error during processing.

    I was trying to put the code in the "ON ERROR GOTO" routine but it says that there was no active transaction....Pls. I need your help.

    Tnx in advance.
    jaroh

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    Perth Western Australia
    Posts
    41

    Question

    Did you set the transaction in progress earlier in your code.... i.e.

    assuming your connection variable is called cn and recordset is rs.

    ------------------------------------------------------------
    On Error Goto ErrorTrap

    sub DoSomething()

    cn.begintrans

    with rs
    .addnew
    .fields("txtData") = "test"
    'Assume this next field should be an integer it will cause an error
    .fields("intData") = "someText"
    .update
    end with
    cn.CommitTrans

    Out:
    Exit Sub
    ErrorTrap:
    cn.rollbackTrans
    resume Out:
    End sub

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