.net 的替代 Oracle 驱动程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/495909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:44:21  来源:igfitidea点击:

Alternative Oracle drivers for .net

c#oracledatabase-connection

提问by Treb

I have to develop a tool in C# that retrieves some data from an Oracle DB. Since our IT support is having some trouble with installing the Oracle client, I want to be able to connect to the database without the client installed. The idea is to just install (and maybe register) an additional library together with the app.

我必须用 C# 开发一个工具来从 Oracle DB 中检索一些数据。由于我们的 IT 支持在安装 Oracle 客户端时遇到了一些问题,我希望能够在不安装客户端的情况下连接到数据库。这个想法是与应用程序一起安装(并且可能注册)一个额外的库。

Which alternatives to the Oracle client exist, and what are their pros and cons?

存在哪些 Oracle 客户端的替代方案,它们的优缺点是什么?

This is for a small application (1 form, 2 or 3 queries, the result displayed in a DataGrid, probably no more than 10-20 data sets), but I am also interested in scalability issues, since we may also move away from the Oracle client with bigger future projects.

这是针对小型应用程序的(1 个表单,2 或 3 个查询,结果显示在 DataGrid 中,可能不超过 10-20 个数据集),但我也对可扩展性问题感兴趣,因为我们也可能远离具有更大未来项目的 Oracle 客户。

Of course a freeware solution would be nice, but we are not limited to that.

当然,免费软件解决方案会很好,但我们不仅限于此。

回答by Igor Zelaya

Your task can be achieved without the need of any third party software:

无需任何第三方软件即可完成您的任务:

  1. Install Oracle Data Access Components 11gin your development box. ODAC 11g is backwards compatible with 9i and 10g
  2. Add a reference to the ODAC library in your .NET projects (Oracle.DataAccess.dll).
  3. Allow your application to connect without the use of TNSNAMES.ORA. To do so, you have to include the connect descriptor in the connection string:

    "user id=scott;password=tiger;data source=" + "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)" + "(HOST=sales-server)(PORT=1521))(CONNECT_DATA="+ "(SERVICE_NAME=sales.us.acme.com)))"

  1. 在您的开发箱中安装Oracle Data Access Components 11g。ODAC 11g 向后兼容 9i 和 10g
  2. 在 .NET 项目 (Oracle.DataAccess.dll) 中添加对 ODAC 库的引用。
  3. 允许您的应用程序在不使用 TNSNAMES.ORA 的情况下进行连接。为此,您必须在连接字符串中包含连接描述符:

    "user id=scott;password=tiger;data source=" + "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)" + "(HOST=sales-server)(PORT=1521))(CONNECT_DATA="+ "( SERVICE_NAME=sales.us.acme.com)))"

Since you are including the connect descriptor in the connection string, the thin client is not required in the targeted computers.

由于您在连接字符串中包含连接描述符,因此目标计算机中不需要瘦客户端。

Happy deployment.

愉快的部署。

回答by Justin Cave

There are a couple different flavors of the Oracle ODP.Net driver. Which version are you trying to use?

Oracle ODP.Net 驱动程序有几种不同的风格。您尝试使用哪个版本?

It sounds like you want the Oracle 11g ODAC 11.1.0.6.21 with Xcopy Deployment, which allows you to deploy the Oracle Instant Client and the ODP.Net driver just by copying a few DLLs over and registering them. That doesn't require a full-blown Oracle client installation.

听起来您想要带有 Xcopy 部署的 Oracle 11g ODAC 11.1.0.6.21,它允许您通过复制几个 DLL 并注册它们来部署 Oracle Instant Client 和 ODP.Net 驱动程序。这不需要完整的 Oracle 客户端安装。

回答by Peder Rice

Oracle currently has a version of ODP.NET that is fully managed, allowing developers to connect to Oracle databases while referencing only a single DLL. There's more information here.

Oracle 目前有一个完全托管的 ODP.NET 版本,允许开发人员在仅引用单个 DLL 的情况下连接到 Oracle 数据库。还有更多的信息在这里

Current releases can be found here.

当前版本可以在这里找到。

回答by Chris Marisic

The enterprise library client System.Data.OracleClient is a viable alternative to the ODP.NET provider from Oracle. There are severla caveats you should know though, using the Microsoft client will make it extremely difficult to work with any type of large objects whether they are XML strings, CLOBs, LOBs or BLOBs. Also the Oracle XmlType column is not supported and must be casted to a CLOB to be returned into the OracleClient.

企业库客户端 System.Data.OracleClient 是 Oracle ODP.NET 提供程序的可行替代方案。但是,您应该知道一些注意事项,使用 Microsoft 客户端将使处理任何类型的大对象变得极其困难,无论它们是 XML 字符串、CLOB、LOB 还是 BLOB。此外,不支持 Oracle XmlType 列,必须将其转换为 CLOB 才能返回到 OracleClient。