Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Property group: Initialization


Type: VT_I2

Typical R/W: R/W

Description: Prompt

Indicates whether to prompt the user during initialization. One of the following values:

  • DBPROMPT_PROMPT — Always prompt the user for initialization information.

  • DBPROMPT_COMPLETE — Prompt the user only if more information is needed.

  • DBPROMPT_COMPLETEREQUIRED — Prompt the user only if more information is needed. Do not allow the user to enter optional information.

  • DBPROMPT_NOPROMPT — Do not prompt the user.

Information obtained from the user during prompting is available following initialization by calling GetProperties for the appropriate initialization properties.

Providers that do not wish to build their own prompting user interface can use IDBPromptInitialize::PromptDataSource, passing in their own data source object as the value of the ppDataSource argument. Such providers are still required to support DBPROP_INIT_PROMPT but can leverage the user interface provided by OLE DB services.

// dbprop_init_prompt.cpp
#undef _ATL_DLL

#define _WIN32_DCOM 

#include <windows.h>
#include <atldbcli.h>
#include <sqloledb.h>


#define CHECKED(_hr) \
   do { \
      if (FAILED(hr = _hr)){ \
         PrintHR(hr); \
         return -1; \
      } \
   } while(0)

#define PrintHR(hr) PrintHR_internal(hr, __FILE__, __LINE__)

void PrintHR_internal(HRESULT hr, char * szFile, ULONG uLine) {
   wprintf(L"Error HR = %d (%x) %hs(%d)\n", hr, hr, szFile, uLine);

int GetDbInitializeFromClsid( IDBInitialize** ppDbInitialize ) {
   HRESULT hr;
   CComPtr< IDBInitialize > pDbInitialize;
   CHECKED( ::CoCreateInstance( CLSID_PROVIDER_TO_USE, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void**)&pDbInitialize ) );

   // Initialize the property values needed to establish the connection.
   DBPROP InitProperty;

   InitProperty.dwPropertyID  = DBPROP_INIT_PROMPT;
   InitProperty.vValue.vt     = VT_I2;
   InitProperty.vValue.iVal   = DBPROMPT_PROMPT;
   InitProperty.dwOptions     = DBPROPOPTIONS_REQUIRED;
   InitProperty.colid         = DB_NULLID;

   DBPROPSET InitPropSet;
   InitPropSet.guidPropertySet = DBPROPSET_DBINIT;
   InitPropSet.cProperties    = 1;
   InitPropSet.rgProperties   = &InitProperty;

   // Set initialization properties.
   CComPtr< IDBProperties > pDbProperties;
   CHECKED( pDbInitialize->QueryInterface(IID_IDBProperties, (void **)&pDbProperties) );
   CHECKED( pDbProperties->SetProperties(1, &InitPropSet) );

   *ppDbInitialize = pDbInitialize.Detach();

   return 0;

int main() {
   HRESULT hr;
   CComPtr<IDBInitialize> pDbInitialize;
© 2015 Microsoft