marcwolf
Posts: 361
|
| Posted: 04/12/2005, 8:13 PM |
|
Hi all.. This is NOT a help question, but a quick HowTo for those who need to use transactions within CCS
I had a need where I wanted to roll back the add of a record if a condition was met. After much investigation I found out how to do it but the object trail was pretty complex so I decided to post it here for others to use.
Firstly and most importantly - make sure that the 'Disable transaction' in your ODBC link is unchecked.
Next in the form's BeforeExecuteInsert put the following
formname.command.connection.connection.begintrans
Then in the form's AfterExecuteInsert do this
If errors> 0 then
formname.errors.adderror "errors have occured"
formname.command.connection.connection.rollbacktrans
else
formname.command.connection.connection.committrans
end if
Now - before the errors test you can do all sorts of inserts/updates/deletes etc and only if all of them have passed then - commit or rollback.
Accessing the form's error collection just adds to the details returned to the viewer, and has nothing to do with the actual rollback operation.
I hope this helps someone as it took me a while to transverse all of the objects and their inheritances.
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|