瀏覽代碼

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

git-svn-id: trunk@3829 -
joost 19 年之前
父節點
當前提交
90b40e9385
共有 1 個文件被更改,包括 3 次插入1 次删除
  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;