Browse Source

fcl-db: mssql: make Rollback more safe. Check if there is active transaction first to avoid error "The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION."
Sometimes SQL Server automaticaly rollbacks transaction and then raises error ...
ODBC driver does same: IF @@TRANCOUNT>0 ROLLBACK.

git-svn-id: trunk@29430 -

lacak 10 years ago
parent
commit
1e3d48288c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

+ 1 - 1
packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

@@ -540,7 +540,7 @@ end;
 
 function TMSSQLConnection.Rollback(trans: TSQLHandle): boolean;
 begin
-  Execute('ROLLBACK');
+  Execute('IF @@TRANCOUNT>0 ROLLBACK');
   Result:=true;
 end;