Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing Param of BDE Alias in runtime. (D1)

28 views
Skip to first unread message

Jerry Adriane Gonçalves

unread,
Jan 10, 2002, 7:42:56 AM1/10/02
to
Hi,

I´m using Delphi 1 to maintain some old applications. These applications not
uses TDatabase for connect to database server. Each TTable or TQuery
existing on applications uses a BDE Alias on DatabaseName property and this
BDE Alias points to a database server. Well now the database server name can
be selected from a list by user and I need change the BDE Alias´ ServerName
parameter before open any TQuery or TTable for connect to correct database
server.

How can I do this ?

PS. This is not my desire but unfortunately include TDatabase component in
applications is out of question.

Thanks in advance

Jerry


Jim Elden

unread,
Jan 10, 2002, 8:15:53 AM1/10/02
to
Jerry,

> How can I do this ?
>

You could use the Components property of your form, something like:

procedure TForm1.SetDBName(ADBName: string);
var i: integer;
begin
for i := 0 to ComponentCount - 1 do begin
if Components[i] is TQuery then TQuery(Components[i]).DatabaseName :=
ADBName;
// then TTable...
end;
end;

I don't have D1 installed to test this.

HTH,
Jim


Kevin Frevert

unread,
Jan 10, 2002, 10:34:57 AM1/10/02
to
Jerry,

Wouldn't a TDatabase solve the problem? Just curious, why is it out of
the question?

krf

Jerry Adriane Gonçalves <je...@tqi.com.br> wrote in message
news:3c3d8b5f_1@dnews...

Kevin Frevert

unread,
Jan 10, 2002, 10:57:38 AM1/10/02
to
And an enhancement to that is have a DatabaseName property for any
forms/datamodules that contain db components...

priviate
FDatabseName :String;
procedure SetDBName(const value :String);
public
property DatabaseName :String read FDatabaseName write SetDBName;
end;

So now whenever you create the form/datamodule

{create of the form/datamodule}
MyFormOrDataModule.DatabaseName := Database1.DatabaseName; {or however you
fetch the alias name}

krf

Jim Elden <x@yz> wrote in message news:3c3d9417_1@dnews...

Jim Elden

unread,
Jan 10, 2002, 9:13:02 AM1/10/02
to
100% Agreed. And introduce the property in a base dm or form.

-Jim


"Kevin Frevert" <kfre...@midwayusa.com> wrote in message
news:3c3d9e15$1_2@dnews...

0 new messages