Board index » delphi » Changing Param of BDE Alias in runtime. (D1)

Changing Param of BDE Alias in runtime. (D1)

Hi,

Im 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

 

Re:Changing Param of BDE Alias in runtime. (D1)


Jerry,

Quote
> 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

Re:Changing Param of BDE Alias in runtime. (D1)


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...

Quote
> How can I do this ?

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

Re:Changing Param of BDE Alias in runtime. (D1)


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

Quote
Jim Elden <x@yz> wrote in message news:3c3d9417_1@dnews...
> 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

Re:Changing Param of BDE Alias in runtime. (D1)


100% Agreed.  And introduce the property in a base dm or form.

-Jim

Quote
"Kevin Frevert" <kfrev...@midwayusa.com> wrote in message

news:3c3d9e15$1_2@dnews...
Quote
> And an enhancement to that is have a DatabaseName property for any
> forms/datamodules that contain db components...

Other Threads