From 3f98f6a5d004b0c2075fc214666b65e26fab96e9 Mon Sep 17 00:00:00 2001 From: joost Date: Thu, 16 Jul 2009 20:45:51 +0000 Subject: [PATCH] * When a dataset is closed and it is not prepared it is assumed that a problem occured, and unprepare is called to clean everything up. But in case the dataset is read from a data-packet, the dataset is also not prepared but no problem occured, so do not call unprepare * Always use AllocateCursorHandle to allocate a cursor, or else its type can be different from what the connection expects git-svn-id: trunk@13397 - --- packages/fcl-db/src/sqldb/sqldb.pp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/fcl-db/src/sqldb/sqldb.pp b/packages/fcl-db/src/sqldb/sqldb.pp index be2cfa6785..d4dca690e3 100644 --- a/packages/fcl-db/src/sqldb/sqldb.pp +++ b/packages/fcl-db/src/sqldb/sqldb.pp @@ -1026,9 +1026,12 @@ end; procedure TCustomSQLQuery.InternalClose; begin - if StatementType in [stSelect,stExecProcedure] then FreeFldBuffers; -// Database and FCursor could be nil, for example if the database is not assigned, and .open is called - if (not IsPrepared) and (assigned(database)) and (assigned(FCursor)) then TSQLConnection(database).UnPrepareStatement(FCursor); + if not IsReadFromPacket then + begin + if StatementType in [stSelect,stExecProcedure] then FreeFldBuffers; + // Database and FCursor could be nil, for example if the database is not assigned, and .open is called + if (not IsPrepared) and (assigned(database)) and (assigned(FCursor)) then TSQLConnection(database).UnPrepareStatement(FCursor); + end; if DefaultFields then DestroyFields; FIsEOF := False; @@ -1216,7 +1219,8 @@ begin ReadFromFile:=IsReadFromPacket; if ReadFromFile then begin - FCursor:=TSQLCursor.Create; + if not assigned(fcursor) then + FCursor := TSQLConnection(Database).AllocateCursorHandle; FCursor.FStatementType:=stSelect; FUpdateable:=True; end