creating alias at run time error 'unknown database alias: myRuntimeAlias'

creating alias at run time error 'unknown database alias: myRuntimeAlias'

Post by jo » Sun, 20 Jun 2004 01:16:00


Hi

Thanks for all the previous help. I do seem to be getting somewhere........

I have managed to set up installshield to allow the user to save the
database files seperatly from the exe, this path is then stored in an ini
file. When the onCreate event of my app's datamodule is executed. It gets
the data concerning the path to database files from the ini, then uses this
to create a subdir for the netfiledir. It also sets the private dir to
c:\win\temp. I then edit the registry and set the local share key for the
borland bde to 'TRUE'. Then I use session.addstandardalias with the data
from the ini concerning the path to databases. However, this seems to have
caused a lot of different errors mostly

'unknown database alias: myRuntimeAlias'

so seemingly my ttable and sql components are not seeing this new alias I am
generating at runtime?

Can anyone shed some light on this please?

I am begining to wonder if it would be better to convert my app to using the
Tdatabase component.....


Many thanks
Jo
 
 
 

creating alias at run time error 'unknown database alias: myRuntimeAlias'

Post by Bruce Robe » Sun, 20 Jun 2004 02:23:53


the

It already does. As with the session, a default database component is
created if you don't add one. I've always found it much easier to explicitly
add these two components.

 
 
 

creating alias at run time error 'unknown database alias: myRuntimeAlias'

Post by jo » Sun, 20 Jun 2004 03:31:58

I have added a tdabase component and set it up with the same name as I was
using for an alias. Double clicked on it and setup as using default
settings. It has got past the alias not found error, but now i get:

file or directory does not exist
file:pdoxusers.net

I'm seem to be going round in circles, and they arnt decreasing! :( Can
anyone point me in the right direction?

This is the code in my datamodule's oncreate event:

begin
session.PrivateDir:='C:\windows\temp';
//config file is written and created by install program
Ini := TIniFile.Create('cmsconfig.ini');
try
{get the dirs from the ini file}
netdir:= Ini.ReadString('Dir', 'networkDir', '');
sDataDir:=ini.readstring('Dir','databaseDir','');
finally
Ini.Free;
end;

//sDataDir comes from ini file above
//modify the standard alias created by tdatabase so path is correct
database1.Params.Clear;
database1.Params.Add(sDataDir);

netdirmsg:='Cannot create ' +netdir;
//create dir for pdoxuser.lck files
if not DirectoryExists(netdir) then
try CreateDir(netdir)
except raise Exception.Create(netdirmsg);
end;

// set the file path
session.NetFileDir:=netdir;
// now change registry so that local share is true
with tregistry.create do
begin
try
RootKey:=HKEY_LOCAL_MACHINE;
if not openKey('SOFTWARE\Borland\Database
Engine\Settings\SYSTEM\INIT',false) then
raise Exception.createfmt('Error setting local share
true',['BDE']);
writeString('LOCAL SHARE','TRUE');
finally
free;
end;
end;
//activate tables and queries at run time
query1.Active:=true;
query2.Active:=true;
tblCWmarks.Active:=true;
qryFBAll.Active:=true;
qryBriefCase.Active:=true;
qryTotals.Active:=true;
etc