Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transactions, commits & rollbacks

Status
Not open for further replies.

atferraz

Technical User
Aug 23, 2003
129
0
0
PT
Helo
how can I apply transaction, commits and rollbacks to a lot of inserts in one script?

thanks anyone
 
Hi

If your connection object is con

con.BeginTrans - Always needed to implement Transactions

con.CommitTrans - Commits the transactions. All SQL statements after BeginTrans are not 'committed' till it finds CommitTrans.

con.RollBackTrans - Aborts all SQL statements between BeginTrans and RollBackTrans.

Hope this helped.

Regards
Satish
 
Something like this

Con.BeginTrans
Con.Execute "Update ........." trans1
Con.Execute "Insert ........." trans2
Con.Execute "Delete ........." trans3

If Con.Errors.Count <> 0 Then
Con.RollbackTrans
Else
Con.CommitTrans All or nothing, right?
End if

 
Con.Open ' open connection
Con.Execute &quot;Update .........&quot; execute trans1
Con.Execute &quot;Insert .........&quot; execute trans2
Con.Execute &quot;Delete .........&quot; execute trans3

also, I do not believe vbscript has .Count for error trapping


_____________________________________________________________________
onpnt2.gif

 
atferraz:

Yes, you got it right. From what I remember, the queries are not 'committed' till you call CommitTrans.

For Error trapping use Err object with On Error Resume Next.

Regards
Satish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top