IDataInitialize::CreateDBInstance

Creates a data source object; analogous to CoCreateInstance.

Syntax

HRESULT CreateDBInstance(
   REFCLSID         clsidProvider,
   IUnknown *       pUnkOuter,
   DWORD            dwClsCtx,
   LPOLESTR         pwszReserved,
   REFIID           riid,
   IUnknown **      ppDataSource);

Parameters

  • clsidProvider [in]
    The CLSID of the provider to instantiate.

  • pUnkOuter [in]
    A pointer to the controlling IUnknown interface if the data source object is being created as a part of an aggregate; otherwise, it is a null pointer.

  • dwClsCtx [in]
    CLSCTX values. CLSCTX_ALL, CLSCTX_SERVER, and CLSCTX_INPROC_SERVER are acceptable values, but the service components will always attempt to load the provider in-process. Ignored if *ppDataSource is not NULL.

  • pwszReserved [in]
    Reserved for future use; must be NULL.

  • riid [in]
    Interface requested on the data source.

  • ppDataSource [out]
    A pointer to memory in which to return the interface pointer on the newly created data source.

Return Code

  • S_OK
    The method succeeded.

  • E_FAIL
    A provider-specific error occurred.

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

    riid was IID_NULL.

    The object indicated by clsidProvider was not an OLE DB provider.

  • E_UNEXPECTED
    The data source object cannot return the requested interface because the data source object is not initialized.

  • DB_E_NOAGGREGATION
    pUnkOuter was not a null pointer, and riid was something other than IID_IUnknown.

    pUnkOuter was not a null pointer, and the provider does not support aggregation.

    dwClsCtx required out-of-process operation, which is not supported.

    The provider does not support in-process operation and cannot be aggregated.

  • E_INVALIDARG
    dwClsCtx was not a valid value.

    ppDataSource was a null pointer.

  • REGDB_E_CLASSNOTREG
    The provider indicated by clsidProvider was not found.

    dwClsCtx indicated a server type not supported by the provider.

Comments

None.