共用方式為


IDBCreateSession::CreateSession

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

Syntax

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

Parameters

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

  • E_INVALIDARG
    ppDBSession was a null pointer.

  • E_NOINTERFACE
    The session did not support the interface specified in riid.

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

  • E_UNEXPECTED
    The data source object was in an uninitialized state.

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

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

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

See Also

Reference

IDBProperties::GetPropertyInfo

ISessionProperties::SetProperties