vfp 通过SQLEXEC来UPDATE ACCESS表,如果执行事务?
更新一个access表,不是SQL表。
DO WHILE .t.
ruanid=ALLTRIM(cuid)
ruanjf=jf
IF EOF()
EXIT
ENDIF
ac=SQLEXEC(handle_bd, "UPDATE cacu SET jf=?ruanjf WHERE cuid=?ruanid")
SELECT temp1
SKIP
ENDDO
如何为这段内容加上事务,确保数据完整性?
[解决办法]
本帖最后由 dkfdtf 于 2012-06-24 03:32:58 编辑
lSuccess = .T.
Locate
SQLSetprop(handle_bd, "transactions", 2)
Scan All
ruanid = Alltrim(cuid)
ruanjf = jf
If SQLExec(handle_bd, "UPDATE cacu SET jf=?ruanjf WHERE uid=?ruanid") <> 1
lSuccess = .F.
Exit
EndIf
EndScan
If lSuccess
Sqlcommit(handle_bd)
Else
Sqlrollback(handle_bd)
EndIf
SQLSetprop(handle_bd, "transactions", 1)