Opens the Data Link Properties dialog box. Returns an uninitialized data source object with the specified properties set.
HRESULT PromptDataSource( IUnknown * pUnkOuter HWND hWndParent, DBPROMPTOPTIONS dwPromptOptions, ULONG cSourceTypeFilter, DBSOURCETYPE * rgSourceTypeFilter, LPCOLESTR pwszszzProviderFilter, REFIID riid, IUnknown ** ppDataSource);
Parameters
Value | Meaning |
---|---|
DBPROMPTOPTIONS_DISABLE_PROVIDER_SELECTION | Do not prompt for provider selection. Valid only if *ppDataSource is a pointer to an existing data source object. Setting this flag without specifying a valid data source object in ppDataSource on input returns the error E_INVALIDARG. |
DBPROMPTOPTIONS_DISABLESAVEPASSWORD | Disables the "Allow Saving password" checkbox. When set, the value of the property DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO is set to VARIANT_FALSE on the provider. |
DBPROMPTOPTIONS_PROPERTYSHEET | Prompt with Data Link Properties dialog box. |
DBPROMPTOPTIONS_WIZARDSHEET | Deprecated. Retained for backward compatibility only. |
Value | Meaning |
---|---|
DBSOURCETYPE_DATASOURCE_TDP | OLE DB tabular data provider |
DBSOURCETYPE_DATASOURCE_MDP | OLE DB multidimensional data provider |
This parameter must be a null pointer or must point to a valid string. If it is non-null, the providers presented to the user will be limited to those that match the providers' ProgIDs specified in pwszszzProviderFilter. If only one provider is specified, the dialog is created with the connection tab displayed. If more than one provider is specified, the provider selection tab is displayed first.
Providers specified in pwszszzProviderFilter that are not registered on the machine are ignored. If none of the providers are registered, an error is returned.
If *ppDataSource is null on entry, IDBPromptInitialize::PromptDataSource generates a new data source object based on the information specified by the user and returns a pointer to that data source object in *ppDataSource.
If *ppDataSource is non-null on entry, IDBPromptInitialize::PromptDataSource uses the properties returned by IProperties::GetProperties as initial values. If the user selects a different provider, PromptDataSource will release the original *ppDataSource and create a new data source object. On exit, *ppDataSource will be set to a pointer to the interface specified by riid. If the user selects the same provider but requests a different interface by supplying a different value for riid, the output value of *ppDataSource will be a pointer to the required interface on the existing data source object.
If *ppDataSource is non-null on entry and the call returns an error, *ppDataSource is untouched. The caller is strongly advised to check the return value when calling IDBPromptInitialize::PromptDataSource on an existing data source object.
Return Code
riid was IID_NULL.
pUnkOuter was not a null pointer, and the provider does not support aggregation.
pUnkOuter and *ppDataSource were both non-null.
cSourceTypeFilter was not zero, and rgSourceTypeFilter was a null pointer.
An element in rgSourceTypeFilter was not a valid filter.
dwPromptOptions was an invalid value.
*ppDataSource was a null pointer, and DBPROMPTOPTIONS_DISABLE_PROVIDER_SELECTION was specified in dwPromptOptions.
*ppDataSource did not refer to a valid data source object.
Comments
Providers that do not support aggregation cannot be initialized via IDBPromptInitialize::PromptDataSource.
Code Example
The following code fragment shows how a consumer might use IDBPromptInitialize::PromptDataSource to prompt the user for connection information:
// First CoCreate the OLE DB Service Component Manager. HRESULT hr = S_OK; IDataInitialize * pIDataInitialize = NULL; hr = CoCreateInstance( CLSID_DataLinks, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, reinterpret_cast<void **>(&pIDataInitialize)); // CreateDBInstance to instantiate previously stored provider. CLSID clsidProvider = GetProviderCLSID(); IDBProperties * pIDBProperties = NULL; hr = pIDataInitialize->CreateDBInstance( clsidProvider, NULL, CLSCTX_INPROC_SERVER, NULL, IID_IDBProperties, reinterpret_cast<IUnknown **>(&pIDBProperties)); // Set some previously stored properties. ULONG cPropertySets = GetPropertySetsCount(); DBPROPSET (*rgPropertySets) = GetPropertySets(); hr = pIDBProperties->SetProperties(cPropertySets, rgPropertySets); // Prompt the user to view/edit the connection information. IDBPromptInitialize *pIDBPromptInitialize = NULL; hr = pIDataInitialize ->QueryInterface( IID_IDBPromptInitialize, reinterpret_cast<void **>(&pIDBPromptInitialize)); hr = pIDBPromptInitialize->PromptDataSource( NULL, hWndParent, DBPROMPTOPTIONS_PROPERTYSHEET, 0, NULL, NULL, IID_IDBProperties, reinterpret_cast<IUnknown **>(&pIDBProperties));