ADO » Connection » ConnectionString

string = connectionobject.ConnectionString
connectionobject.ConnectionString = string

Sets or returns a string value that contains the details used to create a connection to a data source.

Carl Prothman of Able Consulting, Inc. maintains a web site containing sample ADO connection strings for ODBC DSN, ODBC DSN-Less, OLE DB Provider, and MS Remote. The Guru highly recommends you visit this extremely useful site.
The ConnectionString property can be used to set or return a string that contains the information needed to establish a connection to a data source. The string is typically composed of a series of parameter=value statements that are separated by semicolons. After you complete the connection, the provider may alter these ADO parameter=value statements to the provider equivalents.
Note that the ConnectionString string is also passed as part of the Open method call of the Connection object. The values of ConnectionString parameter of the method call are automatically inherited by the ConnectionString property. Therefore, these values are set by the Open method. (Also, the Open method allows the optional use of a user ID and password.)
ADO supports five arguments for the connection string:
File Name= is the name of a file that contains the connection information. If you use this parameter, you cannot use the Provider= parameter.
Provider= is the name of the provider. If you use this parameter, you cannot use the File Name= parameter.
Remote Provider= is the name of the provider that you use when you open a client-side connection. (for Remote Data Service)
Remote Server= is the path name to the server that you use when you open a client-side connection. (for Remote Data Service)
URL= is the absolute URL address to use for the connection.
Note: Duplicate parameters are ignored and only the last occurrence of a repeated parameter is used.


Dim objConnection
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString =
      "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=GuruData.mdb;
objConnection.ConnectionTimeout = 0
'OLE DB Provider for Active Directory Service:

'OLE DB Provider for Index Server:

'OLE DB Provider for Internet Publishing:
"Provider=MSDAIPP.DSO; Data Source="

'OLE DB Provider for Microsoft Jet:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=GuruData.mdb;"

'OLE DB Provider for ODBC Databases:
"Provider=MSDASQL; Driver={SQL Server}; Server=GuruServer;

'OLE DB Provider for Oracle:
"Provider=MSDAORA; Data Source=GuruTable;"<

'OLE DB Provider for SQL Server:
"Provider=SQLOLEDB; Data Source=GuruServer; Network Library=DBMSSOCN;
Initial Catalog=GuruPubs;"

Here are some sample OLE DB ConnectionString examples:

See Also: