views:

377

answers:

1

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?

+3  A: 

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
Just accept your own answer then :-)
Jeroen Pluimers
I can't until 48 hours have passed. :P
Mason Wheeler