TIBCConnection and setting ClientLibrary

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
-ChrisE-
Posts: 17
Joined: Tue 22 Jun 2010 12:40

TIBCConnection and setting ClientLibrary

Post by -ChrisE- » Tue 22 Mar 2011 09:52

Hello,

we use IBDAC 3.50.0.21 with Firebird-Emb 2.5.

We don't install the Firebird-Emb-Files on the maschine. We just put all of them (the hole content of the zip-file from FireBird-Emb-ZIP) into an Subfolder DBLibs of the application.

Now we set the property ClientLibrary of the TIBCConnection to this Path
(+'DBLibs\fbembed.dll').

When we call "connect" this doesn't work. Only if we put some code arround connect like this:

Code: Select all

function TForm1.OwnConnect: Boolean;

var
  origDir: string;
begin
  origDir := GetCurrentDir;
  try
    SetCurrentDir(ExtractFilePath(ExpandFileName(FIBCConnection.ClientLibrary)));
    FIBCConnection.Connect;

    // do some other stuff

  finally
    SetCurrentDir(origDir);
  end;
end;
Is it possible to make this behavior part of the code from IBDAC. So we don't need to put the hole Firebird-Dlls into the Application-Path.

Thank you for help.

Chris

AndreyZ

Post by AndreyZ » Tue 22 Mar 2011 15:12

Hello,

You can set the TIBCConnection.ClientLibrary property to '.\DBLibs\fbembed.dll'. In this case IBDAC will use fbembed.dll that is located in the %Your_Application_Path%\DBLibs directory. But it still will depend on the current directory, and if the current directory isn't the same as your application root directory, IBDAC won't find the fbembed.dll library. To solve this problem you can set the TIBCConnection.ClientLibrary property in the following way:

Code: Select all

IBCConnection.ClientLibrary := ExtractFilePath(Application.ExeName) + 'DBLibs\fbembed.dll';
In this case IBDAC will always use the correct path to the fbembed.dll library that is located in the DBLibs subdirectory of your application root directory.

-ChrisE-
Posts: 17
Joined: Tue 22 Jun 2010 12:40

Post by -ChrisE- » Tue 22 Mar 2011 15:52

I'm sorry.

The error is gone - I don't know why.

We already did it in that way (Full-Path + \DBLibs\fbembed.dll).

Sorry for this post :-(

Chris

AndreyZ

Post by AndreyZ » Wed 23 Mar 2011 07:41

It is good to see that this problem was solved. If any other questions come up, please contact us.

-ChrisE-
Posts: 17
Joined: Tue 22 Jun 2010 12:40

Post by -ChrisE- » Mon 04 Apr 2011 09:02

Hello again ;-)

Now, i have got the error again. And I know how to reproduce:
- Blank system (no Firebird-Installation)
- Own application with an subfolder \DBLibs (content is the whole FBEmb-ZIP 2.5.0)
- Setting ClientLibrary of Connection like this

Code: Select all

IBCConnection.ClientLibrary := ExtractFilePath(Application.ExeName) + 'DBLibs\fbembed.dll';
- Connecting filebased to an Database with

Code: Select all

IBCConnection.Server := '';
IBCConnection.Database := D:\FB_DBs\testdb.db';
IBCConnection.Connect;
So you get an error:
COLLATION UNICODE_CI for CHARACTER SET UTF8 is not installed (Error: -204)
If you make an own connect like this

Code: Select all

function TForm1.OwnConnect: Boolean; 

var 
  origDir: string; 
begin 
  origDir := GetCurrentDir; 
  try 
    SetCurrentDir(ExtractFilePath(ExpandFileName(IBCConnection.ClientLibrary))); 
    IBCConnection.Connect; 

    // do some other stuff 

  finally 
    SetCurrentDir(origDir); 
  end; 
end; 
it works perfect.

Do you have any idea, why there is an difference between connecting to an Server and connecting filebased/direct to an DB?

Thanks for help.

Chris

AndreyZ

Post by AndreyZ » Mon 04 Apr 2011 13:29

This problem is connected with Firebird Embedded, but not with IBDAC. When you are using the UNICODE_CI collation, it cannot find the icuuc30.dll file. This is a quotation from the README_embedded.txt file:
If you want to place the Firebird files (excluding the renamed fbembed.dll) in another directory, you need to modify your firebird.conf and set RootDirectory to the Firebird directory tree. Example:

c:\my_app\app.exe
c:\my_app\gds32.dll
c:\my_app\ib_util.dll
c:\my_app\icudt30.dll
c:\my_app\icuin30.dll
c:\my_app\icuuc30.dll
c:\my_app\firebird.conf
d:\fb\firebird.msg
d:\fb\intl\fbintl.dll
c:\fb\intl\fbintl.conf
d:\fb\udf\fbudf.dll

firebird.conf:
RootDirectory = d:\fb
A you can see, you have to place gds32.dll (renamed fbembed.dll), ib_util.dll, icudt30.dll, icuin30.dll, and icuuc30.dll files to the directory with your application. In this case you won't have such problem. You can find the README_embedded.txt file in the %Firebird_Embedded_Directory%\Doc directory.

-ChrisE-
Posts: 17
Joined: Tue 22 Jun 2010 12:40

Post by -ChrisE- » Mon 04 Apr 2011 13:54

Hello,

thx for this. But there is one thing.

When I connect to an server with this code

Code: Select all

IBCConnection.Server := 'server'; 
IBCConnection.Database := 'testdb'; // Alias-Conf in Server
IBCConnection.Connect;
everything works fine.

I just copy the DB-File from the server to an folder on the maschine and change the Server and Database-Property as described above, recompile and got this error.
Change this propertys back to the server-connection and everythiong works fine.
And when I do the "Workarround" with SetCurrentDir before and after the connect, I can connect to EMB-Files and also to installed servers.

That is reason for this thread.

THX for help,

Chris

BTW: Here are the changes in the Release Notes for FB 2.5 http://firebirdsql.org/rlsnotesh/rlsnot ... ne-embddll for loading the fbemded.dll. They wrote, that we do not longer have to copy the EMB-Files into the app-directory.
And also in the Mailing-List you can find some programmers who have problems with that http://sourceforge.net/mailarchive/foru ... bird-devel They solved the problem also with
- call SetDllDirectory() on the directory where fbembed.dll is before
calling LoadLibrary(), or
- call LoadLibraryEx() with LOAD_WITH_ALTERED_SEARCH_PATH

AndreyZ

Post by AndreyZ » Tue 05 Apr 2011 09:00

This is a specific problem, and you should call the SetCurrentDir function yourself to avoid it.

-ChrisE-
Posts: 17
Joined: Tue 22 Jun 2010 12:40

Post by -ChrisE- » Tue 05 Apr 2011 11:07

Hello,

that's ok for me.

Thanks for support.

Chris

Cilleruelo
Posts: 18
Joined: Tue 09 Mar 2021 16:01

Re: TIBCConnection and setting ClientLibrary

Post by Cilleruelo » Mon 07 Mar 2022 15:12

Important advise!

When you execute your program stand-alone, it is going to search the embedded client in the same folder that the program is executing, but, when you execute the program from the IDE, the current folder is the one in what Delphi IDE is executing. Because of this, all the paths to search the client for using the embedded database are not gonna work.

To execute your program inside the Delphi IDE, you need to have the correspondent Interbase database server, installed in your development computer.


Keep fighting, Ukraina!
Help is on route!

pavelpd
Devart Team
Posts: 109
Joined: Thu 06 Jan 2022 14:16

Re: TIBCConnection and setting ClientLibrary

Post by pavelpd » Wed 09 Mar 2022 12:15

Hi there,
Thank you for your message and for sharing your ideas with us!
We also appreciate your support and kind words. It is very important for us!
Let us know if there are any questions.

Post Reply