简体   繁体   中英

Connect to Firebird 2.5 embedded using FireDAC

No matter what I do, I cant seem to connect to Firebird 2.5 embedded database using FireDAC. Funny thing is that yesterday it seemed to work, now all of a sudden it just won't.

Rather to rake my head why all of a sudden it ceased to work, I begun rebuilding a clean project, so I can figure out step by step what is going on. I added (copied) the entire contents of the downloaded package from Firebird to my application directory and the database itself of course.

To avoid folder issues, I have set the Delphi environment options to put all the files (and the exe) in the same directory. Then I used the suggestion found in the Firebird *.doc folder and renamed fbembed.dll to fbclient.dll. (On some FireDAC Q&A about the issue I have read that Firedac requires fbembed.dll file. Well, I have tried both ways and it won't work anyway). But let me stick to first issue with fbclient.dll.

To establish a connection, I have dropped on the datamodule a FDPhysFBDriverLink1 and a FDConnection1.

Now the FDPhysFBDriverLink1: It's BaseDriverID is FB. For DriverID, I have tried both suggestions: First with 'FB' and then supplying the full path to the fbclient.dll. None seem to make the difference.

When I go to Firedac Connection editor, and input the path to my database file, I get "Cannot load vendor library (fbclient.dll or fbembed.dll)" error. But both of these files are in the application exe folder (like suggested on Embarcadero site). So, where is FireDAC looking for the files? I am getting a little fed up of Firebird and the FireDAC, as they can't simply explain what must be done for the connection to succeed. All they give is some vague options which none of them work. Add this-add that, and at the end, fail.

So if someone has experience on how to do this with straight forward answer (no links please, I have seen and tried them all), I would very much appreciate it. Trying for days to establish a simple connection is really stupid. I have tried also with UniDAC with similar results. What must I do to accomplish the connection?

It seems the issue was this : FDPhysFBDriverLink1 needs this info :

BaseDriverID=FB
DriverID=FB 
VendorLib=C:\Users\***\Documents\Delphi\FIREBIRD\fbembed.dll

After setting this I could connect the FDConnection1 using these parameters :

DriverID=FB
Database=C:\Users\***\Documents\Delphi\FIREBIRD\MYDB.FDB
User_Name=sysdba
Password=masterkey 
Protocol=local

Firebird is a client-server system - it has server part (fbserver.exe or fb_inet_server.exe) and client part (fbclient.dll). So, when you connect to the normal (not embedded) instance of Firebird, you should specify fbclient.dll as a client library.

Embedded Firebird is a combination of server and client in the single dll - they are both complied into fbembed.dll (you can look at its size and compare with fbclient.dll).

When you use Embedded server, you need to specify fbembed.dll as client library, and, as a result, you will have Firebird server (ie, code, responsible for processing SQL queries) embedded into your code.

If you don't specify vendor lib in FireDAC, it will try to load the first available dll, which is most likely will be fbclient.dll (from System32?).

FireDAC, as well as any other client components, are not aware about architecture of Firebird you are using - it just loads specified dll and invokes its API. It gives a great flexibility - you can connect to Embedded, or to SuperServer/Classic/SuperClassic instance, with a single change of client library (and adjusting connection string).

The obvious, but still important thing to mention - Embedded cannot be used for remote connections (with connection string like this: severname:Disk:\\Path\\Database.fdb).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM