Re:IBDatabase should not save Active state in design mode
Hi,
The below-mentioned piece of code is nice, but it is an unwanted hack.
Using the super-duper RAD-IDE-FAST-MODERN app "Delphi", I'd
prefer this annoyance be solved by a somewhat more object-oriented way,
ehh, I mean, like, that the components simply did not project this problem
onto me, the user (developer).
This said, I want to say that I can work with IBX just fine. It's simply a
great
thing!
Back to the code below, it is against my belief to have a library do
something
at startup that I don't need, like opening a database connection.
In my case, I simply want to open the connection at a later moment, not
at startup. So everytime I forget to set connected=false using the mouse,
I get this startup penalty, plus some small unimportant code problems.
Back to the field editor, it is probably the cause for my complaint, as it
is the code that needs to connect (when retrieving the metadata), and it
does not disconnect when done.
It can be compared to a problem my car once had: turning on the blinker
caused the wipers to start wiping! It was a busted fuse. Where are the fuses
in db.pas ?
Thomas
Quote
> procedure TdmMain.TDataBase1BeforeConnect(Sender: TObject);
> var Reg: TRegistry;
> begin
> Reg := TRegistry.Create;
> try
> Reg.Rootkey := HKEY_LOCAL_MACHINE;
> //try to open the key if not found open OpenDialog1 to select a proper
> database
> if not Reg.OpenKey('\Software\Borland\Borland Shared\DataPath',False)
> then
> if OpenDialog1.Execute then
> begin
> Reg.OpenKey('\Software\Borland\Borland Shared\DataPath',True);
> Reg.WriteString('IBPath',OpenDialog1.FileName);
> end;
> IBTransaction1.Active:=False;
> TDataBase1.DatabaseName:=Reg.ReadString('IBPath');
> finally
> Reg.CloseKey;
> Reg.Free;
> end;
> end;
> This way your TDataBase only has to connect once during start-up and the
> DatabaseName is stored outside the application: you have to connect
anyway,
> it always takes time to connect.
> If you are working in a client/server situation, you should be able to
edit
> or change the filename returned by the open dialog depending on the
protocol
> and server type.