BDE aliases are particularly important for BDE session objects, and many methods need to pass a database alias as an argument. TSession provides the ability to manage BDE aliases.
But the author often waits to publish the program only then discovers, your program because cannot find the alias to be able to run, must be in one already installed the BDE management program the machine to be able to use, you must be very disappointed. It doesn't matter, as long as you add the following statement to the program, your program can be executed again.
Addalias is used to create aliases for Paradox, dBASE, or text, requiring no connection parameters, just specifying a path and the default driver.
The Addstandardalias function requires passing three arguments, the name parameter is used to specify the names, the driver parameter is used to specify the SQL links driver, and the list parameter is used to specify the connection parameters.
procedure TForm1.FormCreate(Sender: TObject);
begin
with Session do
begin
ConfigMode := cmSession;
try
AddStandardAlias(WorkMen, ExtractFilePath(ParamStr(0)), PARADOX);
finally
ConfigMode := cmAll;
end;
end;
end;
The above is a stand-alone version of the Create Alias method, as well as the way to create SQL Server alias
procedure TForm1.FormCreate(Sender: TObject);
var MyList: TStringList;
begin
MyList := TStringList.Create;
try
with MyList do
begin
Add(SERVER NAME=IB_SERVER:/PATH/DATABASE.GDB);
Add(USER NAME=MYNAME);
end;
Session1.AddAlias(WorkMen, INTRBASE, MyList);
finally
MyList.Free;
end;
end;
To illustrate, the alias created by invoking the Addstandardalias or Addalias function exists only in memory, and when the program is closed, the alias is saved to the BDE configuration file forever, and the Saveconfigfile function is called to save to the settings file.