Board index » delphi » ModifyAlias

ModifyAlias

After changing an alias name with the ModifyAlias function it does nto
seem to take efect within that session.  I wish to change to location
that all datasoure point to at runtime witht he click of a button.
This would seem to be the right way to accomplish this.  is there a
way to force a session update or some such.  As an example.. I have
four stores, in C:\data\loc1, c:\data\loc2, 3 and 4 etc.. My "data"
alias points to loc1 at start, but user may wish to view contents of
other stores... so I modifyalias to whichever they click.. but does
not seem to take affect.  thanks for any guidance.. Jack

 

Re:ModifyAlias


Quote
Jack wrote:

> After changing an alias name with the ModifyAlias function it does nto
> seem to take efect within that session.  I wish to change to location
> that all datasoure point to at runtime witht he click of a button.
> This would seem to be the right way to accomplish this.  is there a
> way to force a session update or some such.  As an example.. I have
> four stores, in C:\data\loc1, c:\data\loc2, 3 and 4 etc.. My "data"
> alias points to loc1 at start, but user may wish to view contents of
> other stores... so I modifyalias to whichever they click.. but does
> not seem to take affect.  thanks for any guidance.. Jack

You should use TDatabase component like this :

For the first place :
Database1.Connected:=False;
Database1.Databasename:='MYVIRTUALALIAS';
Database1.Params.Clear;
Database1.Params.Add('PATH=C:\data\loc1');
Database1.Connected:=True;
Table1.DatabaseName:='MYVIRTUALALIAS';
Table1.Open;
...
Table1.Close;
Database1.Connected:=False;
Database1.Params.Clear;
Database1.Params.Add('PATH=C:\data\loc2');
Database1.Connected:=True;
Table1.Open;
etc.

You do all this at design time.

Good luck.

Frdric GUILLIEN

Other Threads