>nConn = sqlconnect(connection) > >SQLSetProp(nConn, "Transactions", DB_MANUAL) > >SQLExec("INSERT INTO MYTABLE VALUES MYVALUES") > >SQLDisq(nConn) >>
CLOSE DATABASES all CLEAR ?VERSION() con=SQLCONNECT("LocalServer") && point to any available SQL Server IF con<1 ? "FAILED to connect!!!" RETURN ENDIF cConnString=SQLGETPROP(con,"ConnectString") SQLEXEC(con,"SET ANSI_PADDING ON") SQLEXEC(con,"DROP table testtransaction3") SQLEXEC(con,"create table testtransaction3 (f1 int, f2 char(10))") SQLSETPROP(con,"Transactions",2) SQLEXEC(con,"insert into testtransaction3 values(1,'11111')") SQLEXEC(con,"select @@TRANCOUNT as count", "trancount") ? "Current trancount:",trancount.count *SQLROLLBACK(con) && <==== uncomment this line to see the difference ? "Connection is disconnected!" SQLDISCONNECT(con) ? con=SQLSTRINGCONNECT(cConnString) ? "Connect again and query data" SQLEXEC(con,"select * from testtransaction3","currentstate") SELECT currentstate LIST ?[RECCOUNT()],RECCOUNT() SQLEXEC(con,"DROP table testtransaction3") SQLDISCONNECT(0)VFP output:
Visual FoxPro 08.00.0000.2521 for Windows Current trancount: 1 Connection is disconnected! Connect again and query data Record# F1 F2 1 1 11111 RECCOUNT() 1SQL Profiler output:
Audit Login SQL:BatchCompleted select USER_NAME() select usertype,type,name from systypes where usertype>=257 SQL:BatchCompleted SET ANSI_PADDING ON SQL:BatchCompleted DROP table testtransaction3 SQL:BatchCompleted create table testtransaction3 (f1 int, f2 char(10)) SQL:BatchCompleted set implicit_transactions on SQL:BatchCompleted insert into testtransaction3 values(1,'11111') SQL:BatchCompleted select @@TRANCOUNT as count SQL:BatchCompleted IF @@TRANCOUNT > 0 COMMIT TRAN <============== !!! Audit Logout Audit Login SQL:BatchCompleted select USER_NAME() select usertype,type,name from systypes where usertype>=257 SQL:BatchCompleted select * from testtransaction3 SQL:BatchCompleted DROP table testtransaction3 Audit LogoutThanks,