Browse Source

+ Fixed a crash when connecting to a database fails when using execsql on a query

git-svn-id: trunk@3829 -
joost 19 năm trước cách đây
mục cha
commit
90b40e9385
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      fcl/db/sqldb/sqldb.pp

+ 3 - 1
fcl/db/sqldb/sqldb.pp

@@ -973,7 +973,9 @@ begin
     Prepare;
     Execute;
   finally
-    if (not IsPrepared) and (assigned(database)) then (database as TSQLConnection).UnPrepareStatement(Fcursor);
+    // FCursor has to be assigned, or else the prepare went wrong before PrepareStatment was
+    // called, so UnPrepareStatement shoudn't be called either
+    if (not IsPrepared) and (assigned(database)) and (assigned(FCursor)) then (database as TSQLConnection).UnPrepareStatement(Fcursor);
   end;
 end;