使用 .NET C# 连接到 Interbase 7.1 的最佳方式

发布于 2024-07-06 20:05:05 字数 109 浏览 17 评论 0原文

有人可以解释一下使用 .NET/C# 连接到 Interbase 7.1 数据库的最佳方法吗?

该应用程序将安装在许多最终用户计算机上,因此我必须与应用程序打包的“附加组件”越少越好。

Could someone please explain the best way to connect to an Interbase 7.1 database using .NET/C#?

The application will be installed on many end user computers so the less "add-ons" that I will have to package with my application the better.

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

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

发布评论

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

评论(4

仅此而已 2024-07-13 20:05:05

CodeGear 为 InterBase 的注册用户提供免费的 ADO.NET 2.0 驱动程序:

http://cc.embarcadero.com /item/25497

请注意,“InterBase 注册用户”包括免费的 InterBase 2007 Developers Edition。 下载的内容显示是 2007 年的版本,但它与 InterBase 7 配合得很好,CodeGear 的 InterBase 团队告诉我,他们对人们使用它用于此目的没有任何问题。

我不建议使用为 Firebird 设计的驱动程序,因为 InterBase 和 Firebird 有一些不同的 SQL 语法,并且在其他功能上也有所不同。 特别是,我认为在 InterBase 中使用任何依赖于 fbclient.dll 的驱动程序都是非常危险的。

CodeGear offers a free ADO.NET 2.0 driver for registered users of InterBase here:

http://cc.embarcadero.com/item/25497

Note that "registered users of InterBase" includes the free InterBase 2007 Developers Edition. The download says that it's for 2007, but it works fine with InterBase 7, and the InterBase team at CodeGear has told me that they have no problem with people using it for that purpose.

I do not recommend using a driver designed for Firebird, as InterBase and Firebird have somewhat different SQL syntaxes, and differ in other features, as well. In particular, I think that using any driver dependent on fbclient.dll with InterBase is outright dangerous.

﹏半生如梦愿梦如真 2024-07-13 20:05:05

检查此提供程序:

今天小雨转甜 2024-07-13 20:05:05

我认为 Firebird .net 提供程序与单声道中的提供程序相同。 顺便说一句,两者都很棒。

I think the Firebird .net provider is the same as the one that's in mono. Both are excelent btw.

凡尘雨 2024-07-13 20:05:05

帮助文件中的代码适用于许多情况,但并非所有情况,尤其是在 Windows 8.1、Windows Server 2012 计算机上。

确保您从 embarcadero 获取最新的 InterBase_ADO.NET。 我更新到的版本是 Borland.Data.AdoDbxClient.dll 的版本 16.0.4327.44959。 (右键单击文件、属性、详细信息可查看版本号)。 安装还会为 64 位创建一个 x64 版本文件夹,尽管我没有使用它。 我的目标是 x86,没有任何问题。

不必在每台计算机上都安装 ADO.NET - 您只需将以下文件包含在您的项目中,并在您运行的计算机上安装 Interbase。 我只在我的开发计算机上安装了驱动程序。

安装将提取您需要放入应用程序中以连接到数据库的所有必要文件。 它还将创建用于 InterBase XE 安装和使用说明的自述 ADO_NET 2_0 驱动程序.htm 文件。 重要提示:此帮助 htm 文件中的数据库连接示例并非 100% 有效。 请参阅下面我的代码示例以获取解决方案。

无需 ODBC 连接。 要包含在 .NET 项目中并复制到本地的文件列表为:

  • Borland.Data.AdoDbxClient.dll
  • Borland.Data.DbxCommonDriver.dll
  • Borland.Data.DBXInterBaseDriver.dll
  • Borland.Delphi.dll
  • Borland.VclDbRtl。 dll
  • Borland.VclRtl.dll
  • dbxadapter.dll(x86 或 x64 版本)
  • dbxint.dll(x86 或 x64 版本)
  • gds32.dll(来自 interbase DB 安装)
  • interbase.msg(来自 interbase DB 安装)

我发现了两个连接字符串工作了。 要连接,请使用两个连接字符串之一:

connectionstring1 = "DriverName=Interbase;Database=" + database + ";User_Name=" + userid + ";Password=" + password;
connectionstring1 = connectionstring1 + ";SQLDialect=3;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxReadOnlyMetaData,Version=11.0.5000.0,Culture=neutral,";
connectionstring1 = connectionstring1 + "PublicKeyToken=91d62ebb5b0d1b1b;GetDriverFunc=getSQLDriverINTERBASE;LibraryName=dbxint30.dll;VendorLib=GDS32.DLL";

connectionstring2 = “User_Name="+userid+";Password="+password+";Database="+database+";ServerType=0;Charset=NONE;LibraryName=.\\dbxint.dll;VendorLib=GDS32.DLL;GetDriverFunc=getSQLDriverINTERBASE;SQLDialect=3";


GlobalObjects.dbconn = (TAdoDbxConnection)TAdoDbxInterBaseProviderFactory.Instance.CreateConnection();

GlobalObjects.database = databasepath;
GlobalObjects.dbconn.ConnectionString = connectionstring1;  //or connectionstring2
GlobalObjects.dbconn.Open();

The code in the help file works in many situations but not all, especially on Windows 8.1, Windows Server 2012 machines.

Make sure you get the latest InterBase_ADO.NET from embarcadero. The version I updated to was version 16.0.4327.44959 of Borland.Data.AdoDbxClient.dll. (Right click on file, properties, details to see version number). The install also creates a x64 version folder for 64bit even though I did not use it. I targeted x86 with no issues.

This ADO.NET install is not necessary to do on every machine – you just need to include the below files in your project and have Interbase installed on the machine you are running on. I only installed the driver on my development computer.

The install will extract all the necessary files you need to put in you application to connect to the database. It will also create the readme ADO_NET 2_0 Driver for InterBase XE Installation and Usage Instructions.htm file. IMPORTANT NOTE: the DB connection examples in this help htm file do not work 100% of the time. See my code example below for the solution.

No ODBC connection necessary. The list of the files to be included in your .NET project and to be copied local are:

  • Borland.Data.AdoDbxClient.dll
  • Borland.Data.DbxCommonDriver.dll
  • Borland.Data.DBXInterBaseDriver.dll
  • Borland.Delphi.dll
  • Borland.VclDbRtl.dll
  • Borland.VclRtl.dll
  • dbxadapter.dll (x86 or x64 version)
  • dbxint.dll (x86 or x64 version)
  • gds32.dll (from the interbase DB install)
  • interbase.msg (from the interbase DB install)

I found two connection strings that worked. To connect use one of two connection string:

connectionstring1 = "DriverName=Interbase;Database=" + database + ";User_Name=" + userid + ";Password=" + password;
connectionstring1 = connectionstring1 + ";SQLDialect=3;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxReadOnlyMetaData,Version=11.0.5000.0,Culture=neutral,";
connectionstring1 = connectionstring1 + "PublicKeyToken=91d62ebb5b0d1b1b;GetDriverFunc=getSQLDriverINTERBASE;LibraryName=dbxint30.dll;VendorLib=GDS32.DLL";

connectionstring2 = “User_Name="+userid+";Password="+password+";Database="+database+";ServerType=0;Charset=NONE;LibraryName=.\\dbxint.dll;VendorLib=GDS32.DLL;GetDriverFunc=getSQLDriverINTERBASE;SQLDialect=3";


GlobalObjects.dbconn = (TAdoDbxConnection)TAdoDbxInterBaseProviderFactory.Instance.CreateConnection();

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