|
-
Apr 2nd, 2001, 04:52 AM
#1
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.
-
May 9th, 2001, 01:15 AM
#2
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!
-
May 9th, 2001, 01:33 AM
#3
Addicted Member
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..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|