oracle ODBC 和 ADO.NET 有什么区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34546025/
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-19 03:07:16  来源:igfitidea点击:

What are the differences between ODBC and ADO.NET

oracleado.netodbc

提问by Eran Reuven

I'm devolving a new module that will connect to an Oracle DB over .net 4.5.1.

我正在开发一个新模块,它将通过 .net 4.5.1 连接到 Oracle DB。

  1. Should I use ODBC or ADO.NET and what are the differences between them?

  2. I read that ADO.NET requires an additional installation of an Oracle's client. Is there any way to use the API without installing the additional module?

  1. 我应该使用 ODBC 还是 ADO.NET,它们之间有什么区别?

  2. 我读到 ADO.NET 需要额外安装 Oracle 客户端。有没有办法在不安装附加模块的情况下使用 API?

回答by TallTed

ODBCis a generic, database-agnostic API for C/C+/C++/ObjectiveC-based connections to DBMS, via DBMS-specific ODBC Drivers, which translate to the DBMS-specific API and/or DBMS-specific client layer.

ODBC是一个通用的、数据库不可知的 API,用于基于C/C+/ C++/ ObjectiveC的 DBMS 连接,通过 DBMS 特定的 ODBC 驱动程序,转换为 DBMS 特定的 API 和/或 DBMS 特定的客户端层。

C/C+/C++-based tool
-> ODBC driver 
   -> DBMS libraries
      -> DBMS

ADO.NETis a generic, database-agnostic API, for C#-based connections to DBMS, via DBMS-specific ADO.NET Providers, which translate to the DBMS-specific API and/or DBMS-specific client layer.

ADO.NET是一个通用的、与数据库无关的 API,用于通过特定于 DBMS 的 ADO.NET 提供程序与基于C#的 DBMS 连接,后者转换为特定于 DBMS 的 API 和/或特定于 DBMS 的客户端层。

C#-based tool
-> ADO.NET Provider
   -> DBMS libraries
      -> DBMS

(JDBCand OLE DBare similar generic, database-agnostic API, respectively for Java- and Visual Basic-based connections to DBMS.)

JDBCOLE DB是类似的通用的、与数据库无关的 API,分别用于基于 Java 和Visual Basic的 DBMS 连接。)

Database vendors often provide "checkbox" (meaning, "yes, we have that") ODBC drivers and ADO.NET providers, as well as JDBCdrivers and/or OLE DBproviders, which are not necessarily the best performing nor most fully featured options.

数据库供应商通常提供“复选框”(意思是“是的,我们有那个”)ODBC 驱动程序和 ADO.NET 提供程序,以及JDBC驱动程序和/或OLE DB提供程序,它们不一定是性能最佳或功能最全的选项.

My employerproduces a portfolio of high-performance drivers and providers, supporting a wide range of DBMS; comparison testing with free two-week evaluation license is encouraged. "Single-Tier" options generally require the presence of the DBMS client on the same host; "Multi-Tier" options generally remove this requirement on the data consuming host.

我的雇主生产一系列高性能驱动程序和提供程序,支持范围广泛的 DBMS;鼓励使用为期两周的免费评估许可证进行比较测试。“单层”选项通常需要在同一主机上存在 DBMS 客户端;“多层”选项通常会取消对数据消费主机的这一要求。

C#-based tools cannot connect directly to ODBC drivers, but they can use an ADO.NET Provider for ODBC Data Sourcesto bridge these APIs. There is no speed advantage inherent to ODBC vs ADO.NET, but there is some speed loss for such bridged solutions, due to the extra layer of API translation.

基于 C# 的工具不能直接连接到 ODBC 驱动程序,但它们可以使用用于 ODBC 数据源ADO.NET 提供程序来桥接这些 API。与 ADO.NET 相比,ODBC 没有固有的速度优势,但由于额外的 API 转换层,这种桥接解决方案存在一些速度损失。

C#-based tool
-> ADO.NET Provider
   -> ODBC driver 
      -> DBMS libraries
         -> DBMS

(Microsoft's programming tools use the a Windows built-in ADO.NET-to-ODBC Bridge Provider invisibly and automatically, when you choose an ODBC data source as the target of a C# programming project. My employer also produces such bridge providers, which serve better in many situations.)

(微软的编程工具在你选择一个 ODBC 数据源作为 C# 编程项目的目标时,会不可见地自动使用 Windows 内置的 ADO.NET-to-ODBC Bridge Provider。我的雇主也生产这样的 Bridge Provider,它服务于在许多情况下更好。)

回答by Wernfried Domscheit

ODBC is a generic provider, ODBC drivers are available for almost any data source - even simple CSV-Files.

ODBC 是一个通用提供程序,ODBC 驱动程序几乎可用于任何数据源——甚至是简单的 CSV 文件。

As a drawback you have fewer functions than in ADO.NET and (at least in theory) less performance.

作为一个缺点,您的功能比 ADO.NET 少,并且(至少在理论上)性能更差。

ADO.NET is more strict to connect to a relational database. Please note, the Oracle provider from Microsoft is deprecated, you should not use it for new projects.

ADO.NET 对连接关系数据库更为严格。请注意,Microsoft 的 Oracle 提供程序已弃用,您不应将其用于新项目。

Just for completeness, there is also a third provider called OLE DB(see namespace System.Data.OleDb). The Microsoft OLE DB Provider for Oracle (msdaora) is also deprecated. The provider from Oracle OraOLEDB.Oraclehas still full support.

为了完整起见,还有第三个称为OLE DB 的提供程序(请参阅 namespace System.Data.OleDb)。Microsoft OLE DB Provider for Oracle( msdaora) 也已弃用。Oracle 的提供程序OraOLEDB.Oracle仍然提供全力支持。

For an state-of-the-art connection to Oracle you should use the "Oracle Data Provider for .NET" (ODP.NET), you can download it from here: 64-bit Oracle Data Access Components (ODAC) Downloads

要与 Oracle 建立最先进的连接,您应该使用“Oracle Data Provider for .NET”(ODP.NET),您可以从这里下载:64 位 Oracle 数据访问组件 (ODAC) 下载

All ODBC, OLE DB and ODP.NET require an Oracle Client installation. The only way to bypass it, is to use the "ODP.NET Managed Driver". You can download it also from the same location as above.

所有 ODBC、OLE DB 和 ODP.NET 都需要安装 Oracle 客户端。绕过它的唯一方法是使用“ODP.NET 托管驱动程序”。您也可以从与上述相同的位置下载它。