Databases Reference
In-Depth Information
see in the Appendix C, there are various types of DSNs. A DSN is created using the
ODBC Administrator, which can be activated by clicking on the ODBC icon in the
Windows Control Panel. Appendix C discusses how to use this applet.
Again referring to the output of the ListDPs procedure described earlier, we first note that
the Provider property of the Connection object can be set to either MSDASQL (or its
version-dependent counterpart, MSDASQL.1 ) or the string "Microsoft Jet 3.51 OLE DB
Provider" . Also, since this provider is the default, we can simply omit the Provider
property altogether.
Fortunately, there is some documentation for the Microsoft OLE DB provider for ODBC,
and, equally fortunately, it is quite clearly written, as far as it goes. Here is what the
documentation says about the connect string (this is from the Microsoft MSDN Library
CD):
Because you can omit the Provider parameter, you can therefore compose
an ADO connection string that is identical to an ODBC connection string
for the same data source, using the same parameter names (DRIVER=,
DATABASE=, DSN=, and so on), values, and syntax as you would when
composing an ODBC connection string. You can connect with or without
a predefined data source name (DSN) or FileDSN.
Syntax with a DSN or FileDSN:
“[Provider=MSDASQL;] { DSN=name | FileDSN=filename } ;
[DATABASE=database;] UID=user; PWD=password”
Syntax without a DSN (DSN-less connection):
“[Provider=MSDASQL;] DRIVER=driver; SERVER=server;
DATABASE=database; UID=user; PWD=password”
If you use a DSN or FileDSN, it must be defined through the ODBC
Administrator in the Windows Control Panel. As an alternative to setting a
DSN, you can specify the ODBC driver (DRIVER=), such as
“SQLServer,” the server name (SERVER=), and the database name
(DATABASE=).
You can also specify a user account name (UID=), and the password for
the user account (PWD=) in the ODBC-specific parameters or in the
standard ADO-defined User ID and Password parameters. If you include
both the ADO and the ODBC-specific parameters for these values, the
ADO parameters take precedence.
Although a DSN definition already specifies a database, you can specify a
DATABASE parameter in addition to a DSN to connect to a different
Search WWH ::




Custom Search