'c++builder FDConnection to SQLite after compile the exe
I created a Script with c++Builder 11 with Datas stored in a sqlite3 db File. To Connect to the Sqlite3.db, i used the FireDAC-Connection inside c++builder and all works fine.
In the Connection-Manager (DataExplorer) of C++Builder i set the Path to "D:\TEST.db". If i share the Compiled Exe to another PC, then its possible there is no Drive D. I tried in Connection-Manager to use only the Filename "TEST.db" without Path, but ends in a FireDAC Error Message: "FireDAC..Stan..Definition .. not found in []"...
i also tried "@scriptdir & "\TEST.db" in the Connections-Manager.. but dont works, too...
how can i save my TEST.db (sql3-database) in the ScriptDir if the Connection is fix via "FDConnection1" ????
thanks for any help.. Greeting.
Solution 1:[1]
You could use the BeforeConnect for pointing your FDConnection Object to the correct database file. In the example below it would point to a database file named "test.db3" which is located in your exe's folder:
void __fastcall TForm4::FDConnection1BeforeConnect(TObject *Sender)
{
dynamic_cast< TFDConnection * >( Sender )->Params->Database =
ExtractFileDir( Application->ExeName ) + "\\test.db3";
}
void __fastcall TForm4::Button1Click(TObject *Sender)
{
FDConnection1->Connected = true;
}
best regards, Herwig
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Herwig |
