GERSOFT
asked on
Delphi Alias
I need modify delphi alias from source code, please help me.
What is delphi alias?
and look at: http://www.chami.com/tips/delphi/121796D.html
ASKER
i need modify path from the alias by code:
alias:=getcurrentdir+'\tem p';
// save to new alias path
// procedures.....
alias:=getcurrentdir+'\tem p1';
// save to new alias path...
.
etc.
alias:=getcurrentdir+'\tem
// save to new alias path
// procedures.....
alias:=getcurrentdir+'\tem
// save to new alias path...
.
etc.
Try using the TSession object. It has a method:
procedure AddAlias(const Name, Driver: string; List: TStrings);
I cut and pasted this example from some Delphi documentation:
//------------------------ ---------- ---------- ---------- ---------- ---------- ------
var
MyList: TStringList;
begin
MyList := TStringList.Create;
try
with MyList do
begin
Add('SERVER NAME=IB_SERVER:/PATH/DATAB ASE.GDB');
Add('USER NAME=MYNAME');
end;
Session1.AddAlias('NewIBAl ias', 'INTRBASE', MyList);
finally
MyList.Free;
end;
end;
//------------------------ ---------- ---------- ---------- ---------- ---------- ----------
Hope you can get what you need from this :)
best regards,
jdev
procedure AddAlias(const Name, Driver: string; List: TStrings);
I cut and pasted this example from some Delphi documentation:
//------------------------
var
MyList: TStringList;
begin
MyList := TStringList.Create;
try
with MyList do
begin
Add('SERVER NAME=IB_SERVER:/PATH/DATAB
Add('USER NAME=MYNAME');
end;
Session1.AddAlias('NewIBAl
finally
MyList.Free;
end;
end;
//------------------------
Hope you can get what you need from this :)
best regards,
jdev
ASKER
delete alias and create same alias with new path? no. I need MODIFY alias path.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to use the BDE API function AddAlias.
function DbiAddAlias (hCfg: hDBICfg; pszAliasName: PChar; pszDriverType: PChar; pszParams: PChar; bPersist: Bool): DBIResult stdcall;
This is a nasty looking function call, so I will try to give an example which makes it easier to understand. For further information, you need to look in the BDE API help file and search for the AddAlias function.
1. Add the following units to your uses clause:
uses DB, DbiProcs;
2. Add a procedure like this:
procedure AddMyAlias(AliasName, AliasPath: String);
begin
// Check takes a DbiResult and determines if there is an error
Check(dbiInit(Nil)); // Require in order to use DbiAddAlias
Check(DbiAddAlias(Nil, PChar(AliasName), Nil,
PChar(AliasPath), True));
end;
3. Call the function like this:
AddMyAlias('TestAlias','PA
Regards, SupWang