|
Home > Archive > FoxPro Help and Support > January 2006 > how to transactions with Cursoradapters and sql
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to transactions with Cursoradapters and sql
|
|
|
| I have created a CursorAdapter to insert and update multiple records in a
SQL table.A
After updating/inserting multiple records or so, i need to be able to roll
this action back.
At the moment, if i issue a TABLEUPDATE(.T.), then all the changes are
commited, even if i use a TRANSACTION in the SQL (by issuig BEGIN
TRANSACTION and ROLLBACK in SQLEXEC for the same connection handle stored in
the CursorAdatper).
How can i rollback the changes after having issued a TABLEUPDATE(.T.)?
| |
| Christian Ehlscheid 2006-01-18, 9:24 am |
| Hello,
set the UseTransaction property of the CursorAdapter to .F.
Additionally sending BEGIN TRANSACTION/ROLLBACK commands over SQLEXEC is
not recommend since the ODBC driver state can get out of sync.
Use the provided FoxPro functions instead.
&& switch to manual transactions
SQLSETPROP(yourConne
ction,'Transactions'
,2)
IF TABLEUPDATE(.T.)
SQLCOMMIT(yourConnec
tion)
ELSE
SQLROLLBACK(yourConn
ection)
ENDIF
&& back to automatic transactions
SQLSETPROP(yourConne
ction,'Transactions'
,1)
Regards
Christian
| |
| Christian Ehlscheid 2006-01-18, 9:24 am |
| Hello,
set the UseTransaction property of the CursorAdapter to .F.
Additionally sending BEGIN TRANSACTION/ROLLBACK commands over SQLEXEC is
not recommend since the ODBC driver state can get out of sync.
Use the provided FoxPro functions instead.
&& switch to manual transactions
SQLSETPROP(yourConne
ction,'Transactions'
,2)
IF TABLEUPDATE(.T.)
SQLCOMMIT(yourConnec
tion)
ELSE
SQLROLLBACK(yourConn
ection)
ENDIF
&& back to automatic transactions
SQLSETPROP(yourConne
ction,'Transactions'
,1)
Regards
Christian
|
|
|
|
|