ADO ConnectionString: Difference between revisions
(→External links: added MSDN: Connection String Syntax) |
|||
Line 49: | Line 49: | ||
= External links = | = External links = | ||
*[http://www.connectionstrings.com/ Database connection strings] | *[http://www.connectionstrings.com/ Database connection strings] | ||
*[https://msdn.microsoft.com/en-us/library/windows/desktop/ms722656(v=vs.85).aspx MSDN: Connection String Syntax] | |||
*[http://www.carlprothman.net/Technology/ConnectionStrings/ODBCDSNLess/tabid/90/Default.aspx ODBC DSN-Less connection strings] | *[http://www.carlprothman.net/Technology/ConnectionStrings/ODBCDSNLess/tabid/90/Default.aspx ODBC DSN-Less connection strings] | ||
[[Category:ADO]] | [[Category:ADO]] |
Revision as of 21:19, 28 February 2016
Connection string
The connection string is really just a string inside the application you pass on to the connection object. The property is passed through the Open function of the connection object.
As a string, there are no built in checks or constraints on how to format the connection string. A few rules to follow taken from www.connectionstrings.com
- All blank characters, except those placed within a value or within quotation marks, are ignored
- Blank characters will though affect connection pooling mechanism, pooled connections must have the EXACT same connection string
- If a semicolon (;) is part of a value it must be delimited by quotation marks (")
- Use a single-quote (') if the value begins with a double-quote (")
- Conversely, use the double quote (") if the value begins with a single quote (')
- No escape sequences are supported
- The value type is NOT relevant
- Names are case iNsEnSiTiVe
- If a KEYWORD=VALUE pair occurs more than once in the connection string, the value associated with the LAST occurrence is used. But!... if the PROVIDER keyword occurs multiple times in the string, the FIRST occurrence is used.
- 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.
A connection string consists of a list of argument/value pairs (that is, parameters), separated by semi-colons. For example: "arg1=val1; arg2=val2; ... argN=valN;" All the parameters must be recognized by either ADO or the specified provider. ADO recognizes the following five arguments in a connection string.
Argument | Description |
---|---|
Provider | Specifies the name of a provider to use for the connection. |
File Name | Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information. |
URL | Specifies the connection string as an absolute URL identifying a resource, such as a file or directory. |
Remote Provider | Specifies the name of a provider to use when opening a client-side connection (Remote Data Service only). |
Remote Server | Specifies the path name of the server to use when opening a client-side connection (Remote Data Service only). |
Other arguments are passed to the provider named in the Provider argument, without any processing by ADO.
Depending on the data source you want to connect to the connection string varies.
The following pages document connection strings for OLEDB providers only.
- IBM DB2
- Microsoft Access
- Microsoft Excel
- Microsoft Project
- Microsoft SQL Server
- MySQL
- Oracle Database Server
- SQLite
- Text files