Поделиться через


IDataInitialize::GetInitializationString

Given a data source object, returns a connection string.

HRESULT GetInitializationString(
   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. 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.

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

Prompt (DBPROP_INIT_PROMPT)

The calling application should have control over prompting.

Timeout (DBPROP_INIT_TIMEOUT)

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

General timeout (DBPROP_INIT_GENERALTIMEOUT)

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

OLE DB services (OLEDB_SERVICES)

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.

Note

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.