2

I downloaded the Firebird DBX driver from http://sites.google.com/site/dbxfirebird/ and I've been able to compile the "Test Connection" project and get it to run. I pointed it to my test DB like so:

procedure TMainForm.Button1Click(Sender: TObject);
var C: TSQLConnection;
begin
  C := TSQLConnection.Create(Self);
  try
    C.DriverName := 'FirebirdConnection';
    C.Params.Add('User_Name=SYSDBA');
    C.Params.Add('Password=masterkey');
    C.Params.Add('Database=C:\fbtest\test.fdb');
    C.Open;
    if C.Connected then
      ShowMessage('Connection is active')
  finally
    C.Free;
  end;
end;

When I run it, it works fine. But when I put that exact same code in a different project, it doesn't work. I've copied the fbclient.dll (Firebird embedded driver DLL, renamed to fbclient), all of its dependencies, and the dbxdrivers.ini file to the same folder as the project's EXE is running in. I can't see any reason why this shouldn't work, but the call to .Open fails with:

Project Project1.exe raised exception class TDBXError with message 'Unknown driver: FirebirdConnection'.

Again, this is on the call to Open. The assignment to DriverName works just fine. Has anyone seen this problem before? Why does the exact same code work in the test project but not a different one, and is there any way I can fix it?

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • Mason, I am currently having a problem trying the same thing, if you have an working demo project you could post I would be grateful. – HMcG Aug 22 '11 at 10:05
  • @HMcG: Did my solution below work for you? If not, I'm not sure what the problem is, but you could probably get help by posting a question of your own on here. Reference this post and say "I tried doing what it says in the solution but it still doesn't work, and I'm getting (other error here) instead." – Mason Wheeler Aug 22 '11 at 12:11
  • Yes, thanks. Not the same error, related to my using Fikret Hasovic's Fb_embedded_SRC.pas to embed the .dll into the application .exe. – HMcG Aug 22 '11 at 16:26

3 Answers3

6

I found the problem. A loading class to set up the database driver had to be registered in the initialization section of DBXDynalink.pas. The test project included DBXDynalink in its uses clause, where mine didn't. I put that in and now it works.

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
1

This error generally occurs when you don't add the respective DBX driver unit to your uses list. Try adding DBXFirebird to your uses list.

0

Just change C.DriverName := 'FirebirdConnection'; to C.DriverName := 'Firebird';

and will work!

Edgar
  • 1