For several days, I'm stuck on one debugging point: My application always raised error"Invalid Statement Handle (SQLError -901)" when it proceed the Close signal. I tried all possible solustions, from refactoring other depended units to close their dependencies, but they did not work. This nightmare happened when I use Delphi7 SP1, Enhanced ZeosDBO-6.1.5 Patch 2 and Firebird Embedded Server 1.5. Hours left without any clear path how to fix it. Searching through internet and Zeos forum about this problem still did not work (later, I know that I used the wrong keywords, oh no....).
So I narrow search the problem and focused the debugging point to my ParserEngine. This lead me in clearer situation about the root of the problem. After debugging and searching through Zeos forum deeply for several hours, the root of the problem has been identified. It located at ZDbcConnection.Disconnect procedure.
With small modification on Dbc\ZDbcInterbase6.pas (procedure TZInterbase6Connection.Close), the problem solved.
Before
if FHandle <> nil then
begin
FPlainDriver.isc_detach_database(@FStatusVector, @FHandle);
FHandle := nil;
CheckInterbase6Error(FPlainDriver, FStatusVector, lcDisconnect);
end;
if FHandle <> nil then
begin
if HostName <> '' then
FPlainDriver.isc_detach_database(@FStatusVector, @FHandle);
FHandle := nil;
CheckInterbase6Error(FPlainDriver, FStatusVector, lcDisconnect);
end;