Reputation: 389
I cannot get firebird embedded server to work.
Get an exception at line
datamodule1.IBQuery1.Prepare;
".exe raised exeption class EIBClientError with message 'Database name is missing'."
(IBQuery1 is tied to IBDatabase1)
Im using the server/client dll from this package: Firebird-2.5.3.26778-0_Win32_embed.zip (x86)
I copied the following files (as written in the firebird manual) to my application's folder:
('firebird.conf' does not have to be copied in case you are ok with firebirds default configuration.)
I renamed the fbembed.dll to gds32.dll because im using Delphi's interbase components, but tried the file names fbclient.dll and fbembed.dll also.
For IBDatabase1's 'DatabaseName' property i dont use hostname bacause its stated in the manual that you dont have to in case of using the embedded server (local XNET protocol). I create the path in runtime, been debug this and double checked the path, its correct.
At design time i can connect to the database setting the IBDatabase1's 'Connected' parameter to 'True'. (After manually filling the 'DatabaseName' property with the correct path.)
I searched the system for other firebird client dll's (gds32.dll) and found it at four different location:
It seems that the system using the one that is located in SysWOW64, but even if i replace the dll there to the embedded (fbembed.dll renamed to gds32.dll), nothing changes.
The goal would be not to touch any of the already installed dlls and environment variables/registry entries, but using the embedded dll that is bundled with my application and is located beside that, so making the deployment of the software as easy as you can get.
Some more info:
Was searching for similar topics but yet i could not find solution.
Connect to database:
procedure TDataModule1.DataModuleCreate(Sender: TObject);
begin
IBDatabase1 := TIBDatabase.Create(self);
//
app_path := ExtractFilePath(Application.ExeName);
//
IBDatabase1.DatabaseName := app_path + 'db\XYZ.GDB';
IBDatabase1.LoginPrompt := false;
IBDatabase1.Params.add('lc_ctype=UTF8');
IBDatabase1.Params.add('user_name=xyz'); //not necessary with embedded
IBDatabase1.Params.add('password=xyz'); //not necessary with embedded
//
IBDatabase1.Connected := true;
IBDatabase1.Open;
end;
Then trying to insert a record:
with datamodule1.IBQuery1 do
begin
close;
With SQL do
begin
clear;
Add( 'INSERT INTO MST_EVENTS (index, state, event, param, date, time, devID, gateway)' );
Add( 'VALUES :index, :state, :event, :param, :date, :time, :devid, :gateway');
end;
//
Params[0].AsInteger := FMaster.EventRecordIndex;
Params[1].AsSmallInt := FMaster.EventRecordState;
Params[2].AsString := eventToStr(FMaster.EventRecordEvent);
Params[3].AsSmallInt := 0;
Params[4].AsDate := FMaster.EventRecordDate;
Params[5].AsTime := FMaster.EventRecordTime;
Params[6].AsLongWord := FMaster.EventRecordDevID;
Params[7].AsString := FMaster.EventRecordIP;
//
if ( prepared = false ) then
prepare; //Throws the exception here
open;
end;
Upvotes: 2
Views: 4436
Reputation: 389
This line was the problem.
IBDatabase1 := TIBDatabase.Create(self);
It's totally needless, because the class instance had already been created by the datamodule 'form'.
Upvotes: 1