
Rolling back transactions
I am trying to use a technique to rollback changes to a
number of tables. My objects are structured so that a
data class carries out Fetch/Update/Delete/Insert on a
single table. Question is, how do I pass a connection
object to the low level objects from my business code
layer. Pseudo code would look like this..
Dim cnn As ADODB connection
Set cnn = New ADODB connection
cnn.open ODBC Database
cnn.BeginTrans
updatecustomerobject(cnn)
If not successful Then
cnn.rollback
exit sub
End If
updateaddressobject(cnn)
If not successful Then
cnn.rollback
exit sub
End If
...and so on
cnn.CommitTrans
When I use the conenction object in the object classes I
get an error "The connection cannot be used to perform
this operation. It is either closed or invalid in this
context.". Why? Is there a better way to do this (and
keep my data objects intact)? File of example code
attached.
Thanks for your help.