首页 > 代码库 > 【转载】ODBC, OLEDB, ADO, ADO.Net的演化简史

【转载】ODBC, OLEDB, ADO, ADO.Net的演化简史

原文:ODBC, OLEDB, ADO, ADO.Net的演化简史

 

1.演变历史

它们是按照这个时间先后的顺序逐步出现的,史前->ODBC->OLEDB->ADO->ADO.Net。

看看Wiki上的MDAC定义:“Microsoft Data Access Components(MDAC)是微软专门为数据访问功能而发展的应用程序开发接口,做为微软的统一化数据访问(Universal Data Access; UDA)解决方案的核心组成,最初的版本在1996年时发表,其组成组件有ODBC,OLE DB以及ADO,其中ADO是在Visual Basic上唯一的数据访问管道,而OLE DB则是基于COM之上,供C/C++ 访问与提供数据的接口,ODBC则是统一化的数据访问API。”

也就是说,ODBC, OLE DB, ADO都是这个解决方案的组件。

再看看这张调用图,很多事情就不言自明了。(其实我觉得这图有些不准确,.Net Managed Provider应该有条专线直通Data Stores, 这样才能体现出Sql Server的性能优越性嘛...)

技术分享

2.ODBC之前

事实上, 这几乎都可以称为史前了, 那时数据访问是这个样子滴...

技术分享

 

总结一下就是:以前访问oracle,就要用oracle 的api, 要访问db2,就要用db2的api,这样写出来的代码都是不一样的,一旦领导层要更换数据库,结果程序员就倒血霉了,这不是好方法,ODBC因此应运而生。


3.ODBC

算是较早期的数据访问库,现在已经过时, 但还偶有用处, 看下面图片:

技术分享

下面是其wiki描述:

"In computing, ODBC (Open Database Connectivity) is a standard C programming language interface for accessing database management systems (DBMS). The designers of ODBC aimed to make it independent of database systems and operating systems. An application can use ODBC to query data from a DBMS, regardless of the operating system or DBMS it uses.

ODBC accomplishes DBMS independence by using an ODBC driver as a translation layer between the application and the DBMS. The application uses ODBC functions through an ODBC driver manager with which it is linked, and the driver passes the query to the DBMS."

"ODBC defines a standard C API for accessing a relational DBMS. It was developed by the SQL Access Group in 1992 to standardize the use of a DBMS by an application. ODBC provides a universal middleware layer between the application and DBMS, allowing the application developer to use a single interface. If changes are made to the DBMS specification, only the driver needs updating. An ODBC driver can be thought of as analogous to a printer or other driver, providing a standard set of functions for the application to use, and implementing DBMS-specific functionality.

An application that can use ODBC is referred to as "ODBC-compliant". Any ODBC-compliant application can access any DBMS for which a driver is installed. Drivers exist for all major DBMSs and even for text or CSV files."

"An ODBC driver enables an ODBC-compliant application to use a data source, normally a DBMS. (Some non-DBMS drivers exist, for such data sources as CSV files. Such drivers implement a small DBMS.) ODBC drivers exist for most DBMSs, including Oracle, Microsoft SQL Server (but not for the Compact aka CE edition), Sybase ASE, and DB2.

Because different technologies have different capabilities, most ODBC drivers do not implement all functionality defined in the ODBC standard. Some drivers offer extra functionality not defined by the standard."

 

总结来说:ODBC可以搞定关系型数据库.

4.OLE DB
先看图吧!

技术分享

总结来说: OLE DB的革新, 是它除了能处理关系型数据库, 还能处理非关系型数据了, 如Excel, 这就比ODBC更加进步了.

 

5.ADO

看看下面的图就明白了,一句话,ADO封装了OLE DB。

技术分享

 

技术分享

技术分享

Wiki说法:"Microsoft‘s ActiveX Data Objects (ADO) is a set of Component Object Model (COM) objects for accessing data sources. A part of MDAC, it provides a middleware layer between programming languages and OLE DB (a means of accessing data stores, whether they be databases or otherwise, in a uniform manner). “


一句话:ADO实际上是位于OLE DB顶部的一个附加层(也就是位于OLE DB与应用程序之间), 它封装了OLE DB(精确的说是封装了一个子集,但已经够用了)

用ADO和OLE DB连接SQL数据库的字符串写法相同,都是: connstr="PROVIDER=SQLOLEDB; DATA SOURCE=servername;UID=xx;PWD=xxx;DATABASE=dbname"

只不过ADO的API好用,大家更加熟悉而已,其实,最后还是通过OLE DB来实现的。


6.ADO.Net

车轮滚滚,终于到了Ado.Net.

ADO.NET (ActiveX Data Objects for .NET) is a set of computer software components that programmers can use to access data and data services. It is a part of the base class library that is included with the Microsoft .NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively that it can be considered an entirely new product."

看下图可知,System.Data.SqlClient与System.Data.OleDb的区别, 论性能,SqlClient访问Sql Server最快,论通用性,还是要用OleDb。虽然没有找到System.Data.Odbc的图,但相信它和OleDB的类似。

技术分享

 

7.ODBC与的OLE DB区别

前面已经写过了, 再重申一下, ODBC只能处理关系型数据库, OLE DB不仅能处理关系型数据库, 还能处理非关系型数据库, 如Excel等等.

 

推荐资料:

1.MDAC

http://zh.wikipedia.org/wiki/Microsoft_Data_Access_Components

2.ActiveX Data Objects
http://en.wikipedia.org/wiki/ActiveX_Data_Objects
3.ODBC
http://en.wikipedia.org/wiki/ODBC

4.ODBC、OLEDB、ADO、SQL的关系 
http://www.cnblogs.com/yuanfubiao/archive/2010/12/22/1914149.html

5.ADO,OLEDB,ODBC,DAO的区别 .
http://blog.csdn.net/sunboy_2050/article/details/6624684

6.ADO.Net本质论

7.ADO与ADO.Net编程指南

 

【转载】ODBC, OLEDB, ADO, ADO.Net的演化简史