Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i want to use begintrans,committrans and RollbackTrans on access table and ADO.
    But is required rs.update in the code or CommitTrans have the same result of rs.update???

    Private Sub saveclick()

    On Error GoTo myerror

    conn.BeginTrans

    rs.addnew
    rs(0)=RRRR
    ...
    rs.update


    conn.CommitTrans


    Exit Sub
    myerror:
    conn.RollbackTrans
    MsgBox "Number:" & Err.Number & " Description:" & Err.Description & " Source:" & Err.Source
    'MsgBox Err.Description, vbCritical, "Error Message" & "'" & Str(Err.Number)

    End Sub

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    As I understand it, you need both the rs.update and the CommitTrans in order to get the record saved and unlock the table. BeginTrans automatically locks the table.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    387
    Thanks
    0
    Thanked 1 Time in 1 Post
    .update acts on a single record and is used in DAO recordsets. ADO doesn't require .update.
    BeginTrans and CommitTrans can wrap changes and Adds to multiple records in a recordset so that if there is a failure then none of the records are chaged (or Added")

    so -

    Code:
    cn.BeginTrans
    
    with rs
      do unitl .eof
        !field = !field * 2
      loop
    end with
    cn.CommitTrans
    so in this example, all fields doulbe in value or none do.

Posting Permissions

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