Creates a new session from the data source object and returns the requested interface on the newly created session.


HRESULT CreateSession (
   IUnknown     *pUnkOuter,
   REFIID        riid,
   IUnknown    **ppDBSession);


  • pUnkOuter
    [in] A pointer to the controlling IUnknown interface if the new session is being created as part of an aggregate. It is a null pointer if the session is not part of an aggregate.

  • riid
    [in] The IID of the interface.

  • ppDBSession
    [out] A pointer to memory in which to return the interface pointer.

Return Code

  • S_OK
    The method succeeded.

  • E_FAIL
    A provider-specific error occurred.

    ppDBSession was a null pointer.

    The session did not support the interface specified in riid.

    The provider did not have enough memory to create the session.

    The data source object was in an uninitialized state.

    pUnkOuter was not a null pointer, and the provider is an OLE DB 1.0 or 1.1 provider that does not support aggregation of the session object being created.

    pUnkOuter was not a null pointer, and riid was not IID_IUnknown.

    The maximum number of sessions supported by the provider has already been created. The consumer must release one or more currently held sessions before obtaining a new session object. This error is returned only by providers that have a fixed maximum number of sessions as returned by DBPROP_ACTIVESESSIONS. It is not returned due to other resource constraints, such as available memory (for which the provider returns E_OUTOFMEMORY).

    The provider would have to open a new connection to support the operation, and DBPROP_MULTIPLECONNECTIONS is set to VARIANT_FALSE.

See Also