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

How to connect and use Firebird db embedded server with Visual C# 2010(如何使用 Visual C# 2010 连接和使用 Firebird db 嵌入式服务器)
本文介绍了如何使用 Visual C# 2010 连接和使用 Firebird db 嵌入式服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  1. 已下载 Firebird .Net 数据提供程序(火鸟客户端 v2.5.2).

已下载 Firebird 嵌入式服务器(火鸟嵌入式服务器 v2.5.0).

在我的项目中添加了对 FirebirdSql.Data.FirebirdClient.dll 的引用.

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

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

将我的 FDB 文件 TEST.FDB"添加到我的应用程序的目录中.

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

添加了using FirebirdSql.Data.FirebirdClient;"语句.

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

So far so good (I suppose)...

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

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

我总是收到消息框,这意味着代码没有正确连接到我的数据库文件.难道我做错了什么?我真的还是 C# 的菜鸟,我不知道如何做到这一点或修复它,我希望有人能帮助我.

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.

谢谢:)

这是我在异常中得到的:

here is what I get in the exception:

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和 SettingsermacMy DocumentsVisual工作室2010ProjectsfbTestAppfbTestAppForm1.cs:行25

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 SettingsermacMy DocumentsVisual Studio 2010ProjectsfbTestAppfbTestAppForm1.cs:line 25

推荐答案

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

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

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

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..

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

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..

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

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.

这篇关于如何使用 Visual C# 2010 连接和使用 Firebird db 嵌入式服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)