Board index » delphi » Creating alias at run time ??

Creating alias at run time ??

Creating alias at run time generates an error..

________________________________________________________
The code

procedure TForm1.Button1Click(Sender: TObject);
begin
  Check(DbiAddAlias(Nil, PChar('test'), Nil, PChar('PATH:C:\ABCNET'),
True));
end;

____________________________________________________________
The error

An error occured while attempting to initialize the Borland Database
Engine
(error $2A06)

______________________________________________________________

What is wrong ???

Bernt
Nettsenteret.

 

Re:Creating alias at run time ??


Try using TSession.AddAlias

=Bill=

From the Delphi Help file:
===================
var
 AliasParams: TStringList;
begin
 AliasParams := TStringList.Create;
 try
   with AliasParams do
     Add('OPEN MODE=READ');
     Add('USER NAME=TOMSTOPPARD');
     Add('SERVER NAME=ANIMALS:/CATS/PEDIGREE.GDB');
   end;
   Session.AddAlias('CATS', 'INTRBASE', AliasParams);
   .
   .
   .
 finally
     AliasParams.Free;
 end;
end;

Re:Creating alias at run time ??


Thanks..  :-)  but,
How can I change the path of an existing allias , you see my app is
going to have 2 different databases , somtimes the app  will connect to
one , and some times to another , is it possible to change the path to
the Alias when the app startup...
Quote
WmBurke(TeamB) wrote:

> Try using TSession.AddAlias

> =Bill=

> From the Delphi Help file:
> ===================
> var
>  AliasParams: TStringList;
> begin
>  AliasParams := TStringList.Create;
>  try
>    with AliasParams do
>      Add('OPEN MODE=READ');
>      Add('USER NAME=TOMSTOPPARD');
>      Add('SERVER NAME=ANIMALS:/CATS/PEDIGREE.GDB');
>    end;
>    Session.AddAlias('CATS', 'INTRBASE', AliasParams);
>    .
>    .
>    .
>  finally
>      AliasParams.Free;
>  end;
> end;

Other Threads