The value of a keyword must be specified as a string. The value depends on the property being set and the value that the OLE DB provider expects.
Short Property Values
The Data Link API uses a shortened, "friendlier" version of the property values defined in the OLE DB specification. The short value of a property is derived by removing the prefix from the documented property value and replacing any underscores with spaces. For example, the OLE DB specification defines the following values for the Cache Authentication (DBPROP_AUTH_CACHE_AUTHINFO) property:
VARIANT_TRUE
VARIANT_FALSE
The prefix "VARIANT_" is removed and the short values are TRUE and FALSE.
In connection strings, the short property values are case-insensitive, so the values can be made more readable by using True and False.
Cache Authentication=True
Another example is the Prompt (DBPROP_INIT_PROMPT) property, for which the OLE DB specification defines the following values:
Again, the prefix "DBPROMPT_" is removed, and mixed case can be used for the short values, as follows:
Prompt
Complete
CompleteRequired
NoPrompt
Prompt=Complete
Some of the values defined for the Mode (DBPROP_INIT_MODE) property include the following:
DB_MODE_SHARE_DENY_READ
DB_MODE_SHARE_DENY_WRITE
DB_MODE_SHARE_EXCLUSIVE
The underscores after the prefix "DB_MODE_SHARE_" are replaced with spaces in the short values, as follows:
Deny Read
Deny Write
Share Exclusive
These shortened property values apply only to those properties that are documented in the OLE DB specification. Different OLE DB data providers may use customized properties and property values. The OLE DB Initialization Properties: Quick Reference lists the property description and the short property value (where applicable) for each OLE DB initialization property.
Setting Numeric Values
To set a numeric property value, use a decimal, hex, or octal value, as in the following examples.
Window Handle=123
Window Handle=0x123
Window Handle=0123
Setting Values That Use Reserved Characters
To include values that contain a semicolon, single-quote character, or double-quote character, the value must be enclosed in double quotes.
ExtendedProperties="Data Source='localhost';Integrated Security='SSPI';Initial Catalog='Northwind'"
If the value contains both a semicolon and a double-quote character, the value can be enclosed in single quotes.
ExtendedProperties='Integrated Security="SSPI";Databse="My Northwind DB"'
The value for the ExtendedProperties keyword is Integrated Security="SSPI";Databse="My Northwind DB"
The single quote is also useful if the value begins with a double-quote character.
DataSchema='"MyCustTable"'
The value for the DataSchema keyword is "MyCustTable".
Conversely, the double quote can be used if the value begins with a single quote.
DataSchema="'MyOtherCustTable'"
The value is 'MyOtherCustTable'.
If the value contains both single-quote and double-quote characters, the quote character used to enclose the value must be doubled each time it occurs within the value.
NewRecordsCaption='"Company''s "new" customer"'
The value is "Company's "new" customer".
NewRecordsCaption="""Company's ""new"" customer"""
The value is "Company's "new" customer".
Setting Values That Use Spaces
Any leading or trailing spaces around a keyword or value are ignored. However, spaces within a keyword or value are allowed and recognized.
The value for the MyKeyword keyword is My[space]Value.
MyKeyword= My Value ;MyNextValue=Value
The value for the MyKeyword keyword is My[space]Value.
To include preceding or trailing spaces in the value, the value must be enclosed in either single quotes or double quotes.
The value for the MyKeyword keyword is [space]My[space]Value[space][space].
The value for the MyKeyword keyword is [space][space]My[space]Value[space].
If the keyword does not correspond to a standard OLE DB initialization property (in which case the keyword value is placed in the Extended Properties (DBPROP_INIT_PROVIDERSTRING) property), the spaces around the value will be included in the value even though quote marks are not used. This is to support backward compatibility for ODBC connection strings. Trailing spaces after keywords might also be preserved.
Extended Properties="Driver=SQL Server;uid= MyName;pwd= MyPassword"
The value for the uid keyword is [space]MyName.
The value for the pwd keyword is [space]MyPassword.
Returning Multiple Values
For standard OLE DB initialization properties that can return multiple values, such as the Mode property, each value returned is separated with a pipe (|) character. The pipe character can have spaces around it or not.
Mode=Deny Write|Deny Read