Today I run into a rather curious issue with zConnection.DesignConnection when using Firebird3 Embedded.
When zConnection.DesignConnection = True and zConnection.Database property points to a FDB that does not exist on runtime the application just quits - no error message or anything. Naturally one thinks of a wrongly configured Embedded Server, issues with the connection strings etc. but for sure the last thing that comes to mind is a DesignTime property ...
That was even more annoying as Zeos seems to check on that before the DataModule's OnCreate event is triggered, so no chance for a proper debug session
What exactly is DesignConnection supposed to do and what other effects can I expect during runtime ?
TZConnection.DesignConnection and embedded FB
Moderators: gto, cipto_kh, EgonHugeist
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: TZConnection.DesignConnection and embedded FB
Hello Frank,
FStreamedConnected gets set to True, during the deserialization of the connection component if you set Connected = True at designtime. So basically DesignConnection is a property that says "I might have set Connected to true at designtime but I don't want to automatically connect at runtime. I want that connection at designtime only."
So - usually setting DesignConnection to true should be a safe way to handle things.
Best regards,
Jan
Erm - this is natural to Delphi. Design time properties get applied during the creation of DataModules and Forms. Zeos has to act as soon as properties get set.FrankBKK wrote: ↑26.07.2021, 12:55 When zConnection.DesignConnection = True and zConnection.Database property points to a FDB that does not exist on runtime the application just quits - no error message or anything. Naturally one thinks of a wrongly configured Embedded Server, issues with the connection strings etc. but for sure the last thing that comes to mind is a DesignTime property ...
That was even more annoying as Zeos seems to check on that before the DataModule's OnCreate event is triggered, so no chance for a proper debug session
This is what DesignConnection does at runtime:
Code: Select all
{**
This method is required to support proper component initialization.
Without it, the connection can start connecting before every property is loaded!
}
procedure TZAbstractConnection.Loaded;
begin
inherited Loaded;
try
if FStreamedConnected then
if (csDesigning in ComponentState) or not FDesignConnection then
SetConnected(True);
except
if csDesigning in ComponentState then
if Assigned(Classes.ApplicationHandleException) then
Classes.ApplicationHandleException(ExceptObject)
else
ShowException(ExceptObject, ExceptAddr)
else
raise;
end;
end;
So - usually setting DesignConnection to true should be a safe way to handle things.
Best regards,
Jan
Re: TZConnection.DesignConnection and embedded FB
Hi Jan,
thanks for your prompt and extensive reply.
Hmm, the way you explain it I would agree - that is until the FDB set at design time does not exist at runtime (which I would say is the norm).
I just can't wrap my head around the fact that a design time property - set correctly or wrong - causes the runtime application to simply quit without further notification - I would at least expect an error to be raised.
thanks for your prompt and extensive reply.
So - usually setting DesignConnection to true should be a safe way to handle things.
Hmm, the way you explain it I would agree - that is until the FDB set at design time does not exist at runtime (which I would say is the norm).
I just can't wrap my head around the fact that a design time property - set correctly or wrong - causes the runtime application to simply quit without further notification - I would at least expect an error to be raised.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: TZConnection.DesignConnection and embedded FB
Hmm - this is a part, that I don't understand too. Maybe you can prepare a small sample application that demonstrates the problem? Also I would have to know which Compiler and IDE you use, including version numbers.
Best regards,
Jan