Share via


Given a data source object, returns a connection string.

HRESULT GetInitializationString(
   IUnknown *   pDataSource,
   boolean      fIncludePassword,
   LPOLESTR *   ppwszInitString);


  • 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. If DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO is set to VARIANT_FALSE, the password is not returned, even if fIncludePassword is true. To include the password in the returned initialization string, consumers should make sure that DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO is set to VARIANT_TRUE.

  • 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.

    pDatasource did not indicate an OLE DB data source generated from IDataInitialize or IDBPromptInitialize.

    ppDataSource was a null pointer.

    ppwszInitString was a null pointer.


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 initialization properties listed in the following table 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 good for only that specific instance.


The calling application should have control over prompting.


The property does not apply to the connection itself but to how the connection was established.


The property does not apply to the connection itself but to how the connection was established.


This property does not define the connection but rather specifies how the connection is going to be used. It is possible for multiple applications to use the same connection but with different sets of services.


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.