Question

I am trying to connect to a Interbase DB at runtime via the BDE. I am trying to do this in a formless project (but not a console app). The alias is known. I retrieve the alias from the registry. Example: MyAlias.

//create alias params list  
AParams:= TStringList.Create;  

//create a session to get alias parameters  
ASession:= TSession.Create(nil);  
ASession.SessionName := 'MainSession';  
try  
 ASession.GetAliasParams(tmpAlias, AParams);  
finally  
 ASession.Free;  
end;  


//connect to database 
dbMain:= TDatabase.Create(nil);  
with dbMain do  
begin  
 //AliasName:= 'MyAlias';  
 DatabaseName:= 'test';  
 LoginPrompt:= False;  
 Params.Assign(AParams);  
 try  
  Connected:=True;  
  if Connected then ShowMessage('Connected!') else ShowMessage('Failed to Connect!');    
 finally  
  Free;  
 end; //try  
end;//with  

//free alias params list  
AParams.Free;

Anyway, it doesn't look like the Session.GetParams actually gets the password. How do I get the password? Is there a way to get all the connection info from the BDE and make the connection if I know the alias? I'd rather not hard-code the username and password in case the client changes them in the future.

Was it helpful?

Solution

Shane, if you could get the password from the database only knowing the alias, all the security of the database will be pointless. so the answer is NO , you cannot retrieve this info only knowing the BDE alias. the way to connect to a database with a password protection is request the user and password to the final user or storing this info in an encrypted configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top