OLE DB Programmer's Reference |
Opens the Select Data Link dialog box. Allows the user to browse and organize .udl files. Returns a fully qualified path to the user-selected .udl file.
HRESULT PromptFileName( HWND hWndParent, DBPROMPTOPTIONS dwPromptOptions, LPCOLESTR pwszInitialDirectory, LPCOLESTR pwszInitialFile, LPCOLESTR * ppwszSelectedFile);
Parameters
Value | Meaning |
---|---|
DBPROMPTOPTIONS_BROWSEONLY | Prevents the user from creating new data link files. |
Return Code
dwPromptOptions was an invalid value.
Comments
To load a data source object from a .udl file after calling PromptFileName, the consumer must call IDataInitialize::LoadStringFromStorage to obtain the connection string from the file and then call IDataInitialize::GetDatasource to obtain the data source object based on the connection string.
If the initial directory cannot be accessed, an error message is displayed to the user. If the user chooses to continue, an accessible initial directory will be chosen automatically.
Code Example
The following code fragment shows how a consumer might use IDBPromptInitialize::PromptFileName to prompt the user for a data link (.udl) file:
WCHAR * pwszSelectedFile = NULL; hr = pIDBPromptInitialize->PromptFileName( hWndParent, DBPROMPTOPTIONS_BROWSEONLY, L"C:\\Public", L"*.udl", &pwszSelectedFile);
1998-2001 Microsoft Corporation. All rights reserved.