>Hi All,
>
>Sorry for this beginner's question: Does "Rollback" imply TableRevert()?
>
>Details: I want to use this kind of a structure - does the Rollback effect the TableRevert()-s, which are needed, when some of the TableUpdate()-s fail?
>
>m.llReturnValue = .F.
>Begin Tansaction
>.....
>< Some Loop With m.llReturnValue = m.llReturnValue And TableUptdate(...) >
>.....
>If m.llReturnValue = .T.
> End Transaction
>Else
> Rollback
>Endif
>
>
>Thanks in advance!
>
>Hans
Hi Hans
You will find some tutorials about CA's here. While they were written for VFP8 they are still relevant in 9 because not that much was changed.
http://www.foxite.com/articles/articleindex.htmstarting with :
http://www.foxite.com/articles/read.aspx?id=49&document=creating-using-cursor-adapter-classes-a-simple-tutorialCouple of points:
When using SQLServer data and transactions you are actually managing 2 databases. The VFP tables and the SQL backend. The CA's make it easier but for transactions you still have to manage the code for the backend yourself or you will lose integrity.
If you use defaults and your VFP app crashes during a transaction, the back end will be updated with Orphans etc.
To avoid this it is best to explicitly change the default transaction status to manual and then update the tables involved.
The following snippet will show you how I do it using CA's:
BEGIN TRANSACTION
SQLSETPROP(oConn,"Transactions",2)
If Not Tableupdate(0,.T.,"contract")
Aerror(aer)
Sqlrollback(oConn)
ROLLBACK
SQLSETPROP(oConn,"Transactions",1)
Thisform.logsqlerror()
Messagebox(aer[2])
Return .F.
ELSE
If Not Tableupdate(0,.T.,"SomeOtherTable")
.... code similar to above
ENDIF
ENDIF
Bernard