I'd probably do both, reason being:
a=10
b=0
conn.execute "some sql statement"
conn.execute "update something set this = " & Cint(a/b)
That wouldn't yield a conn.error, but if would give an Err.Number <> 0.
If Err.Number <> 0 Or Conn.Errors.Count <> 0 Then
conn.RollbackTrans
End If
But, better yet, handle this at the database level! Are you using SQL
Server? If so, use stored procedures with error checking and transactions
and things.
Ray at work
"Colin Steadman" <ms**@N0Tpart0FemailADDRESScolinsteadman.com> wrote in
message news:E1**********************************@microsof t.com...
What is the best way to control is a transaction? I've done a little test
and both of the examples below seem to do the job, but I was wondering which
is the better method, this:
If err.number <> 0 Then
conn.RollbackTrans
Else
conn.CommitTrans
End If
Or this:
If conn.Errors.Count <> 0 Then
conn.RollbackTrans
Else
conn.CommitTrans
End If
TIA,
Colin