How to connect and use Firebird db embedded server with Visual C# 2010
Asked Answered
D

4

13

I was trying to use Firebird embedded server with Microsoft Visual C# 2010. so here is what I done till now:

  1. Downloaded Firebird .Net Data Provider (Firebird Client v2.5.2).

  2. Downloaded Firebird Embedded server (Firebird Embedded Server v2.5.0).

  3. Added a reference to FirebirdSql.Data.FirebirdClient.dll to my project.

  4. Extracted and Copied fbembed.dll file to my application's directory.

  5. Added my FDB file "TEST.FDB" to my application's directory.

  6. Added "using FirebirdSql.Data.FirebirdClient;" statement.

So far so good (I suppose)...

Now when I try to connect to my FDB file using the following code:

    FbConnection con = new FbConnection("User=SYSDBA;" + "Password=masterkey;" + "Database=TEST.FDB;" + "DataSource=127.0.0.1;" + "Port=3050;" + "Dialect=3;" + "Charset=UTF8;");
    try  {
             con.Open();
         }
    catch (Exception ex) 
         {
            MessageBox.Show(ex.ToString());
         }

I always get the messagebox which means the code is not connecting to my DB file properly. am I doing something wrong? I'm really still noob with C# and I have no idea how to do this or fix it and I hope someone will help me with this.

thanks :)

EDIT: here is what I get in the exception:

FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Unable to complete network request to host "127.0.0.1". ---> Unable to complete network request to host "127.0.0.1". at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() at FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create() at FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut() at FirebirdSql.Data.FirebirdClient.FbConnection.Open() at fbTestApp.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\ermac\My Documents\Visual Studio 2010\Projects\fbTestApp\fbTestApp\Form1.cs:line 25

Dally answered 25/10, 2010 at 11:29 Comment(2)
Is firebird running at the time you get the exception?Burgeon
nope..firebird embedded server runs only when I click specific button.Dally
D
10

I finally I found the solution after 6 hours of work :)

most of answers on google are either wrong or so old. all of them say that I only need to include fbembed.dll file to my project..

after some investigations I made. I found that I also need to add firebird.msg, firebird.conf, icudt30.dll, icuin30.dll, icuuc30.dll and ib_util.dll to my project files and to the output folder..

important notice: never use compact .Net data provider. because they made it for Normal and super firebird servers only. it won't work with embedded servers.

Dally answered 25/10, 2010 at 14:5 Comment(0)
S
6

With Firebird 2.5 embedded, I copy all this files to the application directory :

aliases.conf (optional)
fbembed.dll
firebird.conf
firebird.msg
ib_util.dll
icudt30.dll
icuin30.dll
icuuc30.dll
Microsoft.VC80.CRT.manifest  : -- Not sure if this 3 files are necessary
msvcp80.dll                  : -- but i copy them :)
msvcr80.dll                  : -- see http://www.firebirdnews.org/?p=2248
intl\fbintl.conf   : Without those files you can't use
intl\fbintl.dll    : all charset and collations
udf\*  : if you want to use pre-build UDF

In the connection string, I specify that the server is embedded wih serverType=1:

User=SYSDBA;Password=masterkey;Database=E:\TEST.FDB;Dialect=3;Charset=UTF8;ServerType=1;

I forgot also IDPLicense.txt and IPLicense.txt, I think we have to also distribute them with the application for license issue ?

Salaidh answered 25/10, 2010 at 22:58 Comment(1)
Runtimes for Firebird 2.1.x. Now, with certain platform exceptions, it is necessary to install the runtimes correctly as an assembly. The minimal runtime consists of three files: msvcr80.dll, msvcp80.dll and the manifest (Microsoft.VC80.CRT.manifest). Necessary!Kine
I
2

I put the Firebird DLLs in a dir in the project called Firebird. Added a Post Build event to copy the files.

copy $(ProjectDir)Firebird\*.dll $(ProjectDir)$(OutDir)*.dll"
Ir answered 28/7, 2012 at 16:26 Comment(0)
A
0

These are the files and distribution you need for Firebird 3.0.5:

- root\plugins\engine12.dll

- root\intl\fbintl.conf
- root\intl\fbintl.dll

- root\fbclient.dll
- root\icudt52.dll
- root\icudt52l.dat
- root\icuuc52.dll

I check them out at the beginning of my application so I can inform what can go wrong.

Alpestrine answered 7/6, 2020 at 18:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.