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.
To reference an .udl file in a connection string, use the File name keyword. For example, if the user selects the file "c:\MyData\Pubs.UDL
", reference the connection string as "File name=c:\MyData\Pubs.UDL
", then use IDataInitialize to get a data source object based on the connection string.
HRESULT PromptFileName(
HWND hWndParent,
DBPROMPTOPTIONS dwPromptOptions,
LPCOLESTR pwszInitialDirectory,
LPCOLESTR pwszInitialFile,
LPCOLESTR * ppwszSelectedFile);
Parameters
hWndParent [in]
The parent window handle for dialog boxes to be displayed. The dialog box will always be centered within this window.
dwPromptOptions [in]
Specifies the dialog box options.
Value | Meaning |
DBPROMPTOPTIONS_NODIRECTORYCHANGE | Prevents the user from changing directories. |
DBPROMPTOPTIONS_BROWSEONLY | Prevents the user from creating new data link files. |
pwszInitialDirectory [in]
A pointer to a string containing the initial directory for the dialog box.
pwszInitialFile [in]
A pointer to a string containing the initial file for the file name edit box of the dialog box.
ppwszSelectedFile [out]
*ppwszSelectedFile points to a string containing the full path to the file the user selected. ppwszSelectedFile cannot be null.
Return Code
S_OK
The method succeeded.
E_FAIL
A provider-specific error occurred.
DB_E_CANCELED
The user canceled the dialog.
E_INVALIDARG
ppwszSelectedFile was a null pointer.
dwPromptOptions was an invalid value.
STG_E_FILENOTFOUND
pwszInitialFile was non-null, and the file was not found.
STG_E_PATHNOTFOUND
pwszInitialDirectory was non-null; pathname does not exist.
STG_E_ACCESSDENIED
pwszInitialDirectory was non-null, and the user has insufficient permission to read from the directory.
STG_E_INVALIDNAME
pwszFileName was an invalid file name.
Comments
None.
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 = pIDBPropmtInitialize->PromptFileName(
hWndParent,
DBPROMPTOPTIONS_BROWSEONLY,
L"C:\\Public",
L"*.udl",
&pwszSelectedFile);