Beginners to understand the difference between OLE DB and ODBC

Source: Internet
Author: User
Tags dsn connect odbc sql ole string access

ODBC (Open Database Interconnection): An early Database interface technology introduced by Microsoft. It is actually the predecessor of ADO. Early database connectivity is very difficult. Each database has a different format, and developers have a deep understanding of the underlying APIs for each database they develop. As a result, generic APIs that can handle a wide variety of databases have emerged. The current ODBC (Open Database Connectivity), ODBC is an early product of people creating generic APIs. There are a number of databases that comply with this standard and are called ODBC-compliant databases.

OLE DB (object link and embedded database) is located between the ODBC layer and the application. In your ASP page, ADO is an "application" located above OLE DB. Your ADO call is sent to OLE DB before it is processed by ODBC. You can connect directly to the OLE DB layer, and if you do, you'll see a performance boost for server-side cursors (the default cursors of the recordset and the most commonly used cursors).

To connect to a database with ODBC:

There are three types of DSNs available in ODBC, and the difference is simple: a user DSN can only be used for this user. The difference between a System DSN and a file DSN is only that the connection information is stored in a different location: The System DSN is stored in an ODBC storage area, and the file DSN is placed in a text file.

The way they are created is not said.

When using them in ASP, the following are written:

A.sql Server:

Using the system dsn:connstr= "DSN=DSNNAME;" Uid=xx; Pwd=xxx;database=dbname "

Use the document Dsn:connstr= "FILEDSN=XX; Uid=xx; Pwd=xxx;database=dbname "

You can also use a connection string (thereby eliminating the need to create a DSN):

Connstr= "Driver={sql SERVER}; Server=servername; Uid=xx; Pwd=xxx "
B.access:

Using the system dsn:connstr= "Dsn=dsnname"

(or for: connstr= "dsn=dsnname; Uid=xx; Pwd=xxx ")

Dsn:connstr= "Filedsn=xx" with file

You can also use a connection string (thereby eliminating the need to create a DSN):

Connstr= "Driver={microsoft Access DRIVER};D Bq=d:\abc\abc.mdb"

To connect to a database with OLE DB:

The following are the referenced contents:
A.sql Server:
Connstr= "PROVIDER=SQLOLEDB;
DATA Source=servername; Uid=xx; Pwd=xxx;database=dbname "
B.access:
Connstr= "Provicer=microsoft. JET. oledb.4.0;
DATA Source=c:\abc\abc.mdb "

It is noteworthy that OLE DB compatibility with ODBC allows OLE DB to access existing ODBC data sources. The advantages are obvious because ODBC is more commonly used relative to OLE DB, so you can get more ODBC drivers than OLE DB. This does not necessarily mean that the driver for the OLE DB can be accessed without immediate access to the original data system.

The provider is located at the OLE DB layer, and the driver is at the ODBC layer. If you want to use an ODBC data source, you need to use an OLE DB Provider for ODBC, and it will then use the appropriate ODBC driver. If you do not need to use an ODBC data source, you can use the appropriate OLE DB providers, which are often referred to as local providers (native provider).

It is clear that using an ODBC provider means that an additional layer is required. Therefore, when accessing the same data, the OLE DB Provider for ODBC may be slower than the local OLE DB provider.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.