Subject Can't close Query when FB is down
Author Guido Klapperich
I want, that my application close all queries, when it recognize, that
the FB-Server is down. Therefore I have built a simple test. I start my
app and then I shut down the FB-Server and then I try to close a query:

procedure TMainForm.ToolButton4Click(Sender: TObject);
begin
if not MainDataModule.Connection.VerifyConnection then
try
ContactsDataModule.CTQuery.Close;
except
end;
end;

When I close the query, I get an exception. The call stack is below. Now
I have two questions:
1) Why tries a statement to prepare/reconnect, when I close the query as
you can see in the call stack.
2) Why do I get an exception even though I close the query in a
try-except-block.

Regards

Guido


Call Stack Information:
--------------------------------------------------------------------------------------------------------------------
|Address |Module |Unit |Class
|Procedure/Method |Line |
--------------------------------------------------------------------------------------------------------------------
| Exception Thread: ID=2464; Priority=0; Class=; [Main]
|
|------------------------------------------------------------------------------------------------------------------|
|00537A40|Impulse.exe |IB_Session.pas |TIB_SessionBase
|HandleException |1155 |
|00537618|Impulse.exe |IB_Session.pas |TIB_SessionBase
|HandleException |1087 |
|004CAF4C|Impulse.exe |IB_Components.pas |TIB_Connection
|AllocateStmtHandle |16658|
|004CAED0|Impulse.exe |IB_Components.pas |TIB_Connection
|AllocateStmtHandle |16640|
|004D2ED7|Impulse.exe |IB_Components.pas |TIB_Statement
|SysAllocate |21214|
|004D304D|Impulse.exe |IB_Components.pas |TIB_Statement
|SysPrepare |21273|
|004D2FF8|Impulse.exe |IB_Components.pas |TIB_Statement
|SysPrepare |21257|
|004DCF05|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysPrepare |26034|
|004D2234|Impulse.exe |IB_Components.pas |TIB_Statement
|Prepare |20859|
|004D2210|Impulse.exe |IB_Components.pas |TIB_Statement
|Prepare |20856|
|004B2770|Impulse.exe |IB_Schema.pas |
|SchemaComputedCols |1013 |
|004B25DC|Impulse.exe |IB_Schema.pas |
|SchemaComputedCols |989 |
|004C4098|Impulse.exe |IB_Components.pas |TIB_SchemaCache
|GetSchemaCacheList |14041|
|004C3DB8|Impulse.exe |IB_Components.pas |TIB_SchemaCache
|GetSchemaCacheList |13979|
|004D06D5|Impulse.exe |IB_Components.pas |TIB_Statement
|GetColumnIsReadOnly |20150|
|004D068C|Impulse.exe |IB_Components.pas |TIB_Statement
|GetColumnIsReadOnly |20147|
|004D9C81|Impulse.exe |IB_Components.pas |TIB_Dataset
|GetColumnIsReadOnly |24506|
|004D9D53|Impulse.exe |IB_Components.pas |TIB_Dataset
|GetControlIsReadOnly |24528|
|0053F5E4|Impulse.exe |IB_FieldDataLink.pas|TIB_FieldDataLink
|GetReadOnly |563 |
|00546EBB|Impulse.exe |IBC_CustomEdit.IMP |TIB_CustomEdit
|EditingChanged |14 |
|00547311|Impulse.exe |IB_Controls.pas |TIB_CustomEdit
|SysStateChanged |1815 |
|00546C26|Impulse.exe |IB_Control.IMP |TIB_CustomEdit
|StateChanged |64 |
|004DF99A|Impulse.exe |IB_Components.pas |TIB_Dataset
|DoLinkStateChanged |27274|
|004DF978|Impulse.exe |IB_Components.pas |TIB_Dataset
|DoLinkStateChanged |27272|
|004E34CB|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysStateChanged |29093|
|004E3470|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysStateChanged |29082|
|004DAA6B|Impulse.exe |IB_Components.pas |TIB_Dataset
|StateChanged |25050|
|004DAA68|Impulse.exe |IB_Components.pas |TIB_Dataset
|StateChanged |25049|
|004DA9D0|Impulse.exe |IB_Components.pas |TIB_Dataset
|SetState |25033|
|004DA960|Impulse.exe |IB_Components.pas |TIB_Dataset
|SetState |25024|
|004E20E7|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysUpdateState |28405|
|004E2050|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysUpdateState |28388|
|004DA93E|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysActiveChange |25009|
|004D3F90|Impulse.exe |IB_Components.pas |TIB_Statement
|SysClose |21678|
|004D3F74|Impulse.exe |IB_Components.pas |TIB_Statement
|SysClose |21674|
|004DC5D4|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysClose |25800|
|004E5D22|Impulse.exe |IB_Components.pas |TIB_BDataset
|GotoBOF |30306|
|004E5CE8|Impulse.exe |IB_Components.pas |TIB_BDataset
|GotoBOF |30300|
|004D90BE|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysKeyDataChange |24129|
|004D9078|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysKeyDataChange |24123|
|004D9142|Impulse.exe |IB_Components.pas |TIB_Dataset
|IB_KeyDataChange |24163|
|004D6D08|Impulse.exe |IB_Components.pas |TIB_Statement
|ProcessLinkEvent |23156|
|004D6CC8|Impulse.exe |IB_Components.pas |TIB_Statement
|ProcessLinkEvent |23152|
|004E35B2|Impulse.exe |IB_Components.pas |TIB_Dataset
|ProcessLinkEvent |29133|
|004D4F18|Impulse.exe |IB_Components.pas |TIB_Statement
|SysAfterFieldDataChange |22207|
|004D4F10|Impulse.exe |IB_Components.pas |TIB_Statement
|SysAfterFieldDataChange |22206|
|004E6521|Impulse.exe |IB_Components.pas |TIB_BDataset
|SysAfterFieldDataChange |30539|
|004DA937|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysActiveChange |25007|
|004D3F90|Impulse.exe |IB_Components.pas |TIB_Statement
|SysClose |21678|
|004D3F74|Impulse.exe |IB_Components.pas |TIB_Statement
|SysClose |21674|
|004DC5D4|Impulse.exe |IB_Components.pas |TIB_Dataset
|SysClose |25800|
|004DB836|Impulse.exe |IB_Components.pas |TIB_Dataset
|Close |25438|
|004DB7A8|Impulse.exe |IB_Components.pas |TIB_Dataset
|Close |25431|
|00903452|Impulse.exe |Main.pas |TMainForm
|ToolButton4Click |1228 |
|77D196C2|user32.dll | |
|DispatchMessageA | |
|77D196B8|user32.dll | |
|DispatchMessageA | |
|0097E213|Impulse.exe |Impulse.dpr | |
|109 |
|------------------------------------------------------------------------------------------------------------------|