About Connection Strings
A connection string is a string version
of the initialization properties needed to connect to a database and enables
you to easily store connection information or to pass it between applications.
Without a connection string, you would be required to store or pass a
complex array of structures to access data. When accessing OLE DB the
connection string is passed as a parameter to create an OLE DB data source
In some cases, rather than using the standard data
link user interface, it might be desirable to build a connection string
within an application—for example, if you want to fine-tune the database
connection properties. In these cases, it is important that the connection
string syntax adhere to the formatting rules described in the following
Basic Connection String Format
The basic format of a connection string is based on the ODBC connection
string. The string consists of a series of keyword/value pairs separated
by semicolons. The equal sign (=) connects each keyword and its value.
The Provider Keyword
The Provider keyword identifies the OLE DB provider to be used.
To specify your OLE DB provider, set the value of the Provider
keyword to the VersionIndependentProgID value of the provider.
The value can also be set to the ProgID of the provider, which may have
a version attached to it.
If two versions of a provider are installed on the same system, use
the ProgID to specify exactly which version to use. If two versions are
installed on a system and the VersionIndependentProgID value is
specified, the most recent version of the provider is used.
If no Provider keyword is in the string, the OLE DB Provider
for ODBC (MSDASQL) is the default value. This provides backward compatibility
with ODBC connection strings. The ODBC connection string in the following
example can be passed in, and it will successfully connect.
If the Provider keyword is specified but names a provider that
does not exist or is invalid, as in the following example, an error is
Specifying a Keyword
To identify a keyword used after the Provider keyword, use the
property description of the OLE DB initialization property that you want
to set. For example, the property description of the standard OLE DB initialization
property DBPROP_INIT_LOCATION is Location. Therefore, to include this
property in a connection string, use the keyword Location.
Note Standard OLE
DB properties are documented under the OLE DB Initialization property
group (DBPROPSET_DBINIT) in Appendix C: OLE DB Properties. For information
about provider-specific initialization properties, see the documentation
that came with your provider.
Keywords can contain any printable character except for the equal sign
(=). All of the following examples are correct.
Jet OLE DB:System Database=c:\system.mda
The keyword is "Jet OLE DB:System Database".
The keyword is "Authentication;Info".
If a keyword contains an equal sign (=), it must be preceded by an additional
equal sign to indicate that it is part of the keyword.
The keyword is "Verification=Security".
If multiple equal signs appear, each one must be preceded by an additional
The keyword is "Many==One".
The keyword is "TooMany=".
About database connections
Connect to existing database
Object Browser elements
Access files with the program
a shortcut to a database on the Shortcut Bar