Pergunta

i create a Data Module with a TSQLConnection component. I set the params by "visual mode". But i dont know, how specify the path of my firebird file save in my projectFolder/store/db.fdb. The project path, may change in the client computer. Any ideas ?.

Foi útil?

Solução

Make sure your connection is not Active in design time.

In FormCreate (or DataModuleCreate) you can do

Sql_componentname.DatabaseName := ExtractFilePath(ParamStr(0)) + 'yourdb.gdb';
Sql_componentname.Active := true;

This is if your db is in the same directory as your program. Otherwise you could set it elsewhere (from ini or userdirectory)

Otherwise: Via an inifile in your applicationdirectory you could do this

iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini')) ;
try
  Sql_componentname.Databasename := iniFile.ReadString('Server','DatabaseName','') ;
finally
  iniFile.Free;
end;

And in the ini

[server]
databasename=projectFolder/store/db.fdb
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top