Object Linking and Embedding, Database (OLE DB) is a more recent protocol that you use to connect an Access database to an external data source such as Microsoft SQL Server. OLE DB does not require a DSN and also provides full access to ODBC data sources and ODBC drivers.

Tip Typically, you use the Data Link Properties dialog box to add an OLE DB connection string. Although there is no way from Access to open the Data Link Properties dialog box, in Windows Explorer, you can create an empty .txt file, change the file type to .udl, and then double-click the file. After you create a connection string, change the file type back to .txt.

Over the years, OLE DB providers have shipped in three phases:

The currently recommended version for new solution development is OLE DB Driver 18 for SQL Server.

How to optimize performance with an ODBC connection string

Soup

To optimize performance, minimize network traffic, and reduce multi-user access to the SQL Server database, use as few connection strings as possible by sharing connection strings over multiple record sets. Although Ace simply passes on a connection string to the server, it does understand and use the following keywords: DSN, DATABASE, UID, PWD, and DRIVER to help minimize client/server communication.

Note If an ODBC connection to an external data source is lost, Access automatically tries to reconnect to it. If the retry is successful, you can continue working. If the retry fails, you can still work with objects that don’t rely on the connection. To reconnect, close and re-open Access.

Recommendations when using both ODBC and OLE DB

Avoid mixing connection string and database access technologies. Use an ODBC connection string for DAO. Use an OLE DB connection string for ADO. If your application contains VBA code that uses both DAO and ADO, then use the ODBC driver for DAO and the OLE DB provider for ADO. Strive to get the latest feature and supports for both ODBC and OLEDB respectively.

ODBC uses the term driver and OLE DB uses the term provider. The terms describe the same type of software component but are not interchangeable in connection string syntax. Use the correct value as documented.

Programmatically interface to SQL Server from Access

There are two main ways to programmatically interface to an SQL Server database from Access.

DAO

A data access object (DAO) provides an abstract interface to a database. Microsoft Data Access Objects (DAO) is the native programming object model that lets you get at the heart of Access and SQL Server to create, delete, modify, and list objects, tables, fields, indexes, relations, queries, properties, and external databases.

For more information, see Microsoft Data Access Objects reference.

ADO

ActiveX Data Objects (ADO) provides a high-level programming model and is available in Access by a reference to a third party library. ADO is straightforward to learn and enables client applications to access and manipulate data from a variety of sources, including Access and SQL Server. Its primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint. ADO also supports key features for building and Web-based applications.

For more information, see Microsoft ActiveX Data Objects reference and Microsoft ActiveX Data Objects (ADO).

Which one should you use?

In an Access solution that uses VBA code, you can use DAO, ADO or both as your database interface technology. DAO continues to be the default in Access. For example, all forms and reports and Access queries use DAO. But when you migrate to SQL Server, consider using ADO to make your solution more efficient. Here are general guidelines to help you decide when to use DAO or ADO.

Use DAO when you want to:

Use ADO when you want to:

Summary of ODBC driver versions

The following table summarize important information about ODBC driver versions, download locations, and feature support. Make sure you use the correct bit version (64-bit or 32-bit) of the driver based on Windows and not Office. If you are running 32-bit Access on 64-bit Windows, install 64-bit drivers, which includes the 32-bit components needed for Access.

For more information, see Using Connection String Keywords with SQL Server Native Client, Release Notes for ODBC to SQL Server on Windows (V17), and Features of the Microsoft ODBC Driver for SQL Server on Windows (V13, 11).

ODBC Drivers
Version
Download
New features
ODBC Drivers 17.0 to 17.3
SQL Server 2017
ODBC Driver 17.3
ODBC Driver 17.2
ODBC Driver 17.1
ODBC Driver 17.0
UseFMTONLY To use legacy metadata in special cases requiring temp tables. See Release Notes for ODBC to SQL Server on Windows
ODBC Driver 13.1
SQL Server 2016 SP1, SQL Azure
ODBC Driver 13.0
SQL Server 2016
Internationalized Domain Name (IDN)
ODBC Driver 11.0
SQL Server 2005 to 2012

Summary of OLE DB provider versions

The following table summarize important information about OLE DB providers versions, download locations, and feature support. Make sure you use the correct bit version (64-bit or 32-bit) of the driver based on Windows and not Office. If you are running 32-bit Access on 64-bit Windows, install 64-bit drivers, which includes the 32-bit components needed for Access.

For more information, see Using Connection String Keywords with SQL Server Native Client.

OLE DB Provider
Version
Download
New features
OLE DB Driver 18.2.1
(MSOLEDBSQL)
SQL Server 2017
See OLE DB Driver for SQL Server Feature and Release notes for the Microsoft OLE DB Driver, for SQL Server
SQL Server Native Client (SQLNCLI)
SQL Server 2005 to 2012
Deprecated, do not use
OLE DB Driver (SQLOLEDB)
Deprecated, do not use

ODBC keyword summary

The following table summarizes the ODBC keywords recognized by SQL Server and their purpose. Only a subset are recognized by Access.

Keyword
Description
Addr
The network address of the server running an instance of SQL Server.
AnsiNPW
Specifies usage of ANSI-defined behaviors for handling NULL comparisons, character data padding, warnings, and NULL concatenation (Yes or No).
APP
Name of the application calling SQLDriverConnect.
ApplicationIntent
Declares the application workload type when connecting to a server (ReadOnly or ReadWrite).
AttachDBFileName
Name of the primary file of an attachable database.
AutoTranslate
Specifies whether ANSI character strings are sent between the client or server or translated to Unicode (Yes or No).
Database
The database name. Description The purpose of the connection. Driver Name of the driver as returned by SQLDrivers.
DSN
Name of an existing ODBC user or system data source. Encrypt Specifies whether data should be encrypted before sending it over the network (Yes or No).
Failover_Partner
Name of the failover partner server to be used if a connection cannot be made to the primary server.
FailoverPartnerSPN
The SPN for the failover partner.
Fallback
Deprecated keyword.
FileDSN
Name of an existing ODBC file data source. Language The SQL Server language.
MARS_Connection
Specifies multiple active result sets (MARS) on the connection for SQL Server 2005 (9.x) or later (Yes or No).
MultiSubnetFailover
Specifies whether to connect to the availability group listener of a SQL Server availability group or a Failover Cluster Instance (Yes or No).
Net
dbnmpntw indicates named pipes and dbmssocn indicates TCP/IP.
PWD
The SQL Server login password.
QueryLog_On
Specifies the logging of long-running queries (Yes or No).
QueryLogFile
Full path and file name of a file to use to log data on long-running queries.
QueryLogTime
Digit character string specifying the threshold (in milliseconds) for logging long-running queries.
QuotedId
Specifies whether SQL Server uses the ISO rules regarding the use of quotation marks in SQL statements (Yes or No).
Regional
Specifies whether the SQL Server Native Client ODBC driver uses client settings when converting currency, date, or time data to character data (Yes or No).
SaveFile
Name of an ODBC data source file into which the attributes of the current connection are saved if the connection is successful.
Server
The name of a SQL Server instance: Server on the network, an IP address, or Configuration Manager alias.
ServerSPN
The SPN for the server.
StatsLog_On
Enables the capture of SQL Server Native Client ODBC driver performance data.
StatsLogFile
Full path and file name of a file used to record SQL Server Native Client ODBC driver performance statistics.
Trusted_Connection
Specifies whether Windows Authentication Mode or SQL Server username or password is used for login validation (Yes or No).
TrustServerCertificate
When used with Encrypt, enables encryption using a self-signed server certificate.
UID
The SQL Server login name.
UseProcForPrepare
Deprecated keyword.
WSID
The workstation identifier, the network name of the computer on which the application resides.

OLE DB keyword summary

The following table summarizes OLE DB keywords recognized by SQL Server and their purpose. Only a subset are recognized by Access.

Keyword
Description
Addr
The network address of the server running an instance of SQL Server.
APP
The string identifying the application.
ApplicationIntent
Declares the application workload type when connecting to a server (ReadOnly or ReadWrite).
AttachDBFileName
Name of the primary file of an attachable database.
AutoTranslate
Configures OEM/ANSI character translation (True or False).
Connect Timeout
The amount of time (in seconds) to wait for data source initialization to complete.
Current Language
The SQL Server language name.
Data Source
The name of an instance of SQL Server in the organization.
Database
The database name.
DataTypeCompatibility
A number indicating the mode of data type handling that will be used.
Encrypt
Specifies whether data should be encrypted before sending it over the network (Yes or No).
FailoverPartner
The name of the failover server used for database mirroring.
FailoverPartnerSPN
The SPN for the failover partner.
Initial Catalog
The database name.
Initial File Name
The name of the primary file (include the full path name) of an attachable database.
Integrated Security
Used for Windows Authentication (SSPI).
Language
The SQL Server language.
MarsConn
Specifies multiple active result sets (MARS) on the connection for SQL Server 2005 (9.x) or later (Yes or No).
Net
The network library used to establish a connection to an instance of SQL Server in the organization.
Network Address
The network address of an instance of SQL Server in the organization.
PacketSize
Network packet size. The default is 4096.
Persist Security Info
Specifies whether persist security is enabled (True or False).
PersistSensitive
Specifies whether persist sensitive is enabled (True or False).
Provider
For SQL Server Native Client, this should be SQLNCLI11.
PWD
The SQL Server login password.
Server
The name of a SQL Server instance: Server on the network, an IP address, or Configuration Manager alias.
ServerSPN
The SPN for the server.
Timeout
The amount of time (in seconds) to wait for data source initialization to complete.
Trusted_Connection
Specifies whether Windows Authentication Mode or SQL Server username or password is used for login validation (Yes or No).
TrustServerCertificate
Specifies whether a server certificate is validated (True or False).
UID
The SQL Server login name.
Use Encryption for Data
Specifies whether data should be encrypted before sending it over the network (True or False).
UseProcForPrepare
Deprecated keyword.
WSID
The workstation identifier, the network name of the computer on which the application resides.

See Also