... ? "Rollback Transaction:",SQLROLLBACK(con) SQLEXEC(con,"select @@TRANCOUNT as count", "trancount") ? "Current trancount:",trancount.count SQLEXEC(con,"select * from #testtransaction","currentstate") SELECT currentstate LIST SQLSETPROP(con,"Transactions",1) <========= here !!! ...I show 6 example for explain.
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLSETPROP(con,"Transactions",1) && this not send commands SQLDISCONNECT(con) && this not send commands Sql Profiler output: -- noneExample B:
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLDISCONNECT(con) && this not send commands Sql Profiler output: -- noneExample C:
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLCOMMIT(con) && this not send commands SQLDISCONNECT(con) && this not send commands Sql Profiler output: -- noneExamples with SQLEXEC.
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLEXEC(con,"",1) && send set implicit_transactions on SQLSETPROP(con,"Transactions",1) && send IF @@TRANCOUNT > 0 COMMIT TRAN SQLDISCONNECT(con) && this not send commands Sql Profiler output: SQL:BatchCompleted: set implicit_transactions on SQL:BatchCompleted: SQL:BatchCompleted: IF @@TRANCOUNT > 0 COMMIT TRANExample B1:
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLEXEC(con,"",1) && send set implicit_transactions on SQLDISCONNECT(con) && send IF @@TRANCOUNT > 0 COMMIT TRAN Sql Profiler output: SQL:BatchCompleted: set implicit_transactions on SQL:BatchCompleted: SQL:BatchCompleted: IF @@TRANCOUNT > 0 COMMIT TRANExample C1:
con=SQLCONNECT("LocalServer") && point to any available SQL Server SQLSETPROP(con,"Transactions",2) && this not send commands SQLEXEC(con,"",1) && send set implicit_transactions on SQLCOMMIT(con) && send IF @@TRANCOUNT > 0 COMMIT TRAN SQLDISCONNECT(con) && this not send commands Sql Profiler output: SQL:BatchCompleted: set implicit_transactions on SQL:BatchCompleted: SQL:BatchCompleted: IF @@TRANCOUNT > 0 COMMIT TRANOn VFP, on one ODBC transaction=2, this command are identical:
* command A SQLSETPROP(con,"Transactions",1) * command B SQLDISCONNECT(con) * command C SQLCOMMIT(con)This is the cause of the problem.