Given a data source object, returns a connection string.
HRESULT GetInitString(
IUnknown * pDataSource,
Boolean fIncludePassword,
LPOLESTR * ppwszInitString);
Parameters
pDatasource [in]
A pointer to a data source object.
fIncludePassword [in]
Whether or not to include the password property, if specified, in the returned initialization string.
ppwszInitString [out]
Returned connection string containing information necessary to re-create the data source object and current properties.
Return Code
S_OK
The method succeeded.
E_FAIL
A provider-specific error occurred.
E_NOINTERFACE
pDatasource did not indicate an OLE DB data source generated from IDataInitialize or IDBPromptInitialize.
E_INVALIDARG
ppDatasource was a null pointer.
ppwszInitString was a null pointer.
Comments
The string returned defines the connection and its current settings. This is done by returning a string version of all of the initialization properties set on the data source object.
The following initialization properties are not included in the string returned by this method:
Initialization Property | Why the Property is Not Returned in the Connection String |
Asynchronous Processing (DBPROP_INIT_ASYNCH) | When the user connects asynchronously, the way the consumer is using the connection information is more relevant than the connection itself. |
Window Handle (DBPROP_INIT_HWND) | The value is only good for that specific instance. |
Prompt (DBPROP_INIT_PROMPT) | The calling application should have control over prompting. |
Locale Identifier (DBPROP_INIT_LCID) | Not including this property allows users to share connection strings across different locales. |
The password (DBPROP_AUTH_PASSWORD) property, if returned, is treated just like all other initialization properties. It is not encrypted or masked in any way.