ODBC Programmer's Reference Committing and Rolling Back Transactions To commit or roll back a transaction in manual-commit mode, an application calls SQLEndTran. Drivers for DBMSs that support transactions typically implement this function by executing a COMMIT or ROLLBACK statement. The Driver Manager does not call SQLEndTran when the connection is in auto-commit mode; it simply returns SQL_SUCCESS, even if the application attempts to roll back the transaction. Because drivers for DBMSs that do not support transactions are always in auto-commit mode, they can either implement SQLEndTran to return SQL_SUCCESS without doing anything or not implement it at all. Note Applications should not commit or roll back transactions by executing COMMIT or ROLLBACK statements with SQLExecute or SQLExecDirect. The effects of doing this are undefined. Possible problems include the driver no longer knowing when a transaction is active and these statements failing against data sources that do not support transactions. These applications should call SQLEndTran instead.Please educate yourself, read a book about ODBC, read a book about ODBC transaction management. If you are still not happy with the way ODBC driver handles your calls, talk to whoever developed it.
>... >? "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 !!! >... >>
>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: >-- none >>
>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: >-- none >>
>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: >-- none >>
>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 TRAN >>
>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 TRAN >>
>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 TRAN >>
>* command A >SQLSETPROP(con,"Transactions",1) > >* command B >SQLDISCONNECT(con) > >* command C >SQLCOMMIT(con) >>