Hi there
Have written small script to add records to various tables.
Run as a SQL Script (on Advantage Database OLEDB connection), SQL script works fine. However, I want to run this as a processed transaction , if one fails then roll all back.
However, when using commandtext, will not rollback if errors occur.
SQL is broken in 5, Update, Insert(Using select), Insert(Using Select), Insert(Using Values), Update. All in this order.
In order to run script I have imported the SQL in to an array split on ";". then I use
cn.Open 'Open DB Connection
cn.BeginTransaction
For i = Lbound(arrMyArray) to UBound(arrMyArray)
cmd.CommandText = arrMyArray(i)
cmd.Execute
Next
If cn.Errors.Count <> 0 Then
Blah Blah....
cn.RollbackTrans
cn.Errors.Clear
Else
'All OK
cn.CommitTrans
cn.Close
Have written small script to add records to various tables.
Run as a SQL Script (on Advantage Database OLEDB connection), SQL script works fine. However, I want to run this as a processed transaction , if one fails then roll all back.
However, when using commandtext, will not rollback if errors occur.
SQL is broken in 5, Update, Insert(Using select), Insert(Using Select), Insert(Using Values), Update. All in this order.
In order to run script I have imported the SQL in to an array split on ";". then I use
cn.Open 'Open DB Connection
cn.BeginTransaction
For i = Lbound(arrMyArray) to UBound(arrMyArray)
cmd.CommandText = arrMyArray(i)
cmd.Execute
Next
If cn.Errors.Count <> 0 Then
Blah Blah....
cn.RollbackTrans
cn.Errors.Clear
Else
'All OK
cn.CommitTrans
cn.Close