如何连接和使用火鸟分贝嵌入式服务器使用Visual C#2010 [英] How to connect and use Firebird db embedded server with Visual C# 2010

查看:518
本文介绍了如何连接和使用火鸟分贝嵌入式服务器使用Visual C#2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用火鸟嵌入式服务器与Microsoft Visual C#2010。
所以这是我做的到现在:


  1. 下载火鸟.NET数据提供程序(<一个href=\"http://sourceforge.net/projects/firebird/files/firebird-net-provider/2.5.2/NETProvider-2.5.2-CF.7z/download\">Firebird客户端V2.5.2 )。


  2. 下载火鸟嵌入式服务器(<一个href=\"http://sourceforge.net/projects/firebird/files/firebird-win32/2.5-Release/Firebird-2.5.0.26074-0_Win32_embed.zip/download\">Firebird嵌入式服务器V2.5.0 )。


  3. 增加了引用FirebirdSql.Data.FirebirdClient.dll ,以我的项目。


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


  5. 加了我FDB文件的TEST.FDB我的应用程序的目录。


  6. 增加了使用FirebirdSql.Data.FirebirdClient; 。声明


到目前为止好(我想)...

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

  FbConnection CON =新FbConnection(用户= SYSDBA;+密码= masterkey;+=数据库TEST.FDB;+数据源= 127.0.0.1;+ 端口= 3050;+方言= 3;+字符集= UTF8;);
    尝试{
             con.Open();
         }
    赶上(异常前)
         {
            MessageBox.Show(ex.ToString());
         }

我总是这意味着code未连接到我的数据库文件中正确的消息框。
我做错了什么?我真的还是小白用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:\\文件
  和设置\\ ermac \\我的文档\\ Visual
  工作室
  2010 \\项目\\ fbTestApp \\ fbTestApp \\ Form1.cs中:行
  25



解决方案

我终于找到我工作6小时后,该解决方案:)

大多数对谷歌的答案要么是错误的或者很老。
所有的人说,我只需要包括fbembed.dll文件到我的项目。

一些调查后,我做了。我发现,我还需要添加的 firebird.msg,firebird.conf,icudt30.dll,icuin30.dll,icuuc30.dll和ib_util.dll 我的项目 文件,并在输出文件夹 ..

重要通知:从不使用紧凑的.NET数据提供程序。因为他们使其成为正常和唯一的超级火鸟服务器。它不会与嵌入式服务器工作。

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

解决方案

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.

这篇关于如何连接和使用火鸟分贝嵌入式服务器使用Visual C#2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆