如何通过 Visual C# 2010 连接和使用 Firebird db 嵌入式服务器

发布于 2024-09-28 18:21:18 字数 1950 浏览 1 评论 0原文

我试图将 Firebird 嵌入式服务器与 Microsoft Visual C# 2010 一起使用。 所以这是我到目前为止所做的:

  1. 下载Firebird .Net Data Provider (Firebird 客户端 v2.5.2)。

  2. 已下载Firebird嵌入式服务器Firebird 嵌入式服务器 v2.5.0)。

  3. 向我的项目添加了对 FirebirdSql.Data.FirebirdClient.dll 的引用

  4. fbembed.dll 文件提取并复制到我的应用程序的目录。

  5. 将我的 FDB 文件“TEST.FDB”添加到我的应用程序的目录。

  6. 添加了“using FirebirdSql.Data.FirebirdClient;”语句。

到目前为止一切顺利(我想)...

现在,当我尝试使用以下代码连接到我的 FDB 文件时:

    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());
         }

我总是收到消息框,这意味着代码未正确连接到我的 DB 文件。 我做错了什么吗?我真的还是 C# 菜鸟,我不知道如何执行此操作或修复它,我希望有人能帮助我。

谢谢:)

编辑:这是我在异常中得到的:

FirebirdSql.Data.FirebirdClient.FbException (0x80004005):无法完成 对主机“127.0.0.1”的网络请求。 --->无法完成对主机“127.0.0.1”的网络请求。在 FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() 在 FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create() 在 FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut() 在 FirebirdSql.Data.FirebirdClient.FbConnection.Open() 在 fbTestApp.Form1.button1_Click(对象 发送者、EventArgs e) 在 C:\Documents 中 和设置\ermac\我的文档\Visual 工作室 2010\项目\fbTestApp\fbTestApp\Form1.cs:行 25

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月流歌 2024-10-05 18:21:18

经过 6 个小时的工作,我终于找到了解决方案:)

谷歌上的大多数答案要么是错误的,要么太旧了。
他们都说我只需要将 fbembed.dll 文件包含到我的项目中..

经过我做了一些调查。我发现我还需要将 firebird.msg、firebird.conf、icudt30.dll、icuin30.dll、icuuc30.dll 和 ib_util.dll 添加到我的项目 文件并保存到输出文件夹

重要通知:切勿使用紧凑的 .Net 数据提供程序。因为他们只为普通和超级火鸟服务器制作。它不适用于嵌入式服务器。

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.

终遇你 2024-10-05 18:21:18

嵌入 Firebird 2.5 后,我将所有这些文件复制到应用程序目录中:

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

在连接字符串中,我指定服务器是嵌入的 serverType=1:

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

我还忘记了 IDPLicense.txt 和 IPLicense.txt,我认为我们还必须分发他们与申请牌照有关吗?

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 ?

Oo萌小芽oO 2024-10-05 18:21:18

我将 Firebird DLL 放在名为 Firebird 的项目中的目录中。添加了构建后事件来复制文件。

copy $(ProjectDir)Firebird\*.dll $(ProjectDir)$(OutDir)*.dll"

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"
岁月打碎记忆 2024-10-05 18:21:18

这些是 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

我在应用程序开始时检查它们,以便我可以告知可能出现的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文