Results 1 to 3 of 3

Thread: Rollback Transactions

  1. #1
    noGuru
    Guest

    Talking

    How do you roll back/commit database transactions in VBScript? This is serious because data can get lost when one record's "latest" field (a bit field) is unchecked and a power failure or error occur before a new record can be added! Please give some advise. Thanks.

  2. #2
    noGuru
    Guest

    Ek het reeds

    Thanks for trying, but I managed to use

    cnConnect.BeginTrans

    at the top and

    cnConnect.CommitTrans

    at the bottom of the page, where cnConnect is the Connection object. There's no need for a cnConnect.Rollback statement, because the above worked perfectly. Any case, there's no such thing as "On error goto errorhandler" in VBScript, that's why the Rollback statement will never be executed anyway.

    e=m*c^2 rules!

  3. #3
    Addicted Member rikshawdriver's Avatar
    Join Date
    Apr 2001
    Posts
    160

    I may be wrong, but..

    If you don't handle the transaction properly, I mean if you leave any transactions imcomplete, it may lead to blocking the database resources. When you start a transaction actually you block the records and other resources so the other users will be unable to perform any write operations on the related data. So you must use the following structure.

    cnConnect.BeginTrans

    If error then
    cnConnect.CommitTrans
    else
    cnConnect.Rollbacktra..
    end if

    VBScript supports On Error Resume Next (I think, it is not documented by MS)

    So you can trap the errors by
    err.clear
    on error resume next
    ...
    If err.number <> 0 then
    ...
    end if

    As I said I may be totally wrong..
    Thomas

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