What is difference in adodb and oledb?

TheVillageIdiot picture TheVillageIdiot · Sep 22, 2010 · Viewed 43.4k times · Source

What is the difference between adodb and oledb?

What is the relation between these two?

Where does ado.net stands in context of adodb and oledb?

Answer

Sidharth Panwar picture Sidharth Panwar · Sep 22, 2010

Adodb (ActiveX Data Objects DB) is an API layer over OLE DB. It works well with MS-based databases such as Sql Server, providing a consistent API and optimizations. That being said you can use ADODB to connect with non-MS data sources as well but that would mean that you will require an OLEDB/ODBC Provider for the data source.

In simpler terms, to connect to any data source you need a driver. Here are a couple of common scenarios to think of:

  1. ADODB for Data Source that has ODBC Driver Only - ADODB uses OLEDB Provider for ODBC which loads ODBC Driver which then connects to Data Source.
  2. ADODB for Data Source with OLEDB Driver (like SQL Server) - ADODB uses OLEDB Provider for SQL Server to talk directly with DB.

Oledb (Object Linking and Embedding DB) is a standard format supported by a large number of dbs, so you can connect to oracle, db2 etc. using Oledb. You can also use OLEDB directly to connect to Sql Server but the API is messier as compared to a adodb connection which is optimized to work with Sql Server and MS Access.

ADO.Net is a .Net based db connection "architecture". In ADO.Net there's a library for Oledb - System.Data.OledbClient. Adodb has been replaced/upgraded and ADO.Net now uses the System.Data.SqlClient library for MS-based databases/data providers.