General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
James:
VFP transaction do not affect Sql server , you should set a manuall transaction in Sql server to perform the updates, i send a pice of code using cursor adapter and transaction in sql server.
* nHandle means your connection handle
lnResult = SQLSetProp(nHandle,"TRANSACTIONS",2) &&
LOCAL ok as Boolean
ok=.f.
FOR i=1 TO AUSED(atablas)
ok=TABLEUPDATE(1,.T.,i)
IF ok=.f.
=AERROR(lerror)
SQLROLLBACK(nHandle)
EXIT
ENDIF
ENDFOR
IF ok=.t.
SQLCOMMIT(nHandle)
ms='1-Actualización correcta'
ELSE
ms=lerror(1,3)
ENDIF
=SQLSETPROP(nHandle,"Transactions",1)
oconn1=null
oconn2=null
oconn3=null
oconn4=null
oconn5=null
=SQLDISCONNECT(nHandle)
RETURN(ms)
HTH
jUAN
>I use CursorAdapter to connect to an SQLServer table. I can insert records to the SQLServer table via CA. But how do I rollback the changes in the SQLServer table? Or is it better to control the commit/rollback in SQLServer?
>
>I've tried using "begin transaction", "rollback", "tableupdate()" and "tablerevert()", (see below). The CA is reverted OK, but the SQLServer table is not.
>
>Thanks
>James
>
>
> set multilocks on
>
> locursor = createobject('SQLAdapter')
>
> with loCursor
>
> if .cursorfill(.f., .t.)
>
> begin transaction
>
> insert into Transact values ('IS00000005', 'JC ')
> insert into Transact values ('IS00000006', 'JC ')
>
> browse
>
> = tableupdate(1)
>
> rollback
>
> browse
>
> =TABLEREVERT(.t.)
>
> brow
>
> else
>
> * dimension laErros[1]
> aerror(laErrors)
> messagebox(laErrors[2])
>
> endif
>
> endwith
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only