The code below shows how to connect to a database at runtime.

procedure TdmBarcode.DataModuleCreate(Sender: TObject);
begin
with session do
begin
ConfigMode := cmSession;
try
{creates a local alias pointing to the application directory.
Note that this alias is automatically deleted when the application
terminates and will not be saved to the BDE configuration file.}
AddStandardAlias('BarcodeTemp', ExtractFilePath(ParamStr(0)), 'PARADOX');

with dbBarcode do
begin
AliasName := 'BarcodeTemp';
DatabaseName := 'BarcodeDB';
Connected := true;
end; //dbBarcode

with tblBarcode do
begin
DatabaseName := 'BarcodeDB';
TableName := 'barcode.db';
Active := true;
end; //with tblBarcode

AddStandardAlias('StockTemp', ExtractFilePath(ParamStr(0)), 'PARADOX');

with dbStock do
begin
AliasName := 'StockTemp';
DatabaseName := 'StockDB';
Connected := true;
end; //dbStock

with tblStock do
begin
DatabaseName := 'StockDB';
TableName := 'stock.db';
Active := true;
end; //with tblStock

finally
ConfigMode := cmAll;
end;
end; //with session
end; 
procedure TdmBarcode.DataModuleDestroy(Sender: TObject);
begin
dsBarcode.DataSet.Close ;
end;