SQLReadFileDSN
Version Introduced: ODBC 3.0
Summary
SQLReadFileDSN reads information from a File DSN.
Syntax
BOOL SQLReadFileDSN(
Arguments
lpszFileName [Input]
lpszAppName [Input]
lpszKeyName [Input]
lpszString [Output]
If *lpszFileName is a valid .DSN file name, but the lpszAppName argument is a null pointer and the lpszKeyName argument is a null pointer, then *lpszString contains a list of valid applications. If *lpszFileName is a valid .DSN file name, and *lpszAppName is a valid application name, but the lpszKeyName argument is a null pointer, then *lpszString contains a list of valid reserved keywords in the appropriate section of the
DSN file, delimited by semicolons. If *lpszFileName is a valid .DSN file name, but *lpszAppName is a null pointer, and the lpszKeyName argument is a null pointer, then *lpszString contains a list of the sections in the DSN file, delimited by semicolons.
cbString [Input]
pcbString [Output]
Returns
The function returns TRUE if it is successful, FALSE if it fails.
Diagnostics
When SQLReadFileDSN returns FALSE, an associated *pfErrorCode value may be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.
LPCSTR lpszFileName,
LPCSTR lpszAppName,
LPCSTR lpszKeyName,
LPSTR lpszString,
WORD cbString,
WORD * pcbString);
Pointer to the data buffer containing the name of the .DSN file. A DSN
extension is appended to all file names that do not already have a DSN extension. The
value in *lpszFileName must be a null-terminated string.
Pointer to the data buffer containing the name of the application. This is
ODBC” for the ODBC section. The value in *lpszAppName must be a null-terminated string.
Pointer to the data buffer containing the name of the key to be read. See
Comments” for reserved keywords. The value in *lpszAppName must be a null-terminated string.
Pointer to the data buffer containing the string associated with the key to be
read.
Length of the *lpszString buffer.
Total number of bytes available to return in *lpszString. If the number of bytes available to return is greater than or equal to cbString, the output string in *lpszString is truncated to cbString minus the null-termination character. The pcbString argument can be a null pointer.
*pfErrorCode
| Error
| Description
|
ODBC_ERROR_ GENERAL_ERR | General installer error
| An error occurred for which there was no specific installer error.
|
ODBC_ERROR_
INVALID_BUFF_ LEN | Invalid buffer length
| The lpszString argument was NULL.
The cbString argument was less than or equal to 0. |
ODBC_ERROR_
INVALID_ PATH | Invalid install path
| The path of the file name specified in the lpszFileName argument was invalid.
|
ODBC_ERROR_
INVALID_ REQUEST_TYPE | Invalid type of request
| The lpszAppName argument was NULL while the lpszKeyName argument was valid.
|
ODBC_ERROR_
OUT_OF_MEM | Out of memory
| The installer could not perform the function because of a lack of memory.
|
ODBC_ERROR_
OUTPUT_ STRING_ TRUNCATED | Output string truncated
| The string returned in *lpszString was truncated because the value in cbString was less than or equal to the value in *pcbString.
|
ODBC_ERROR
REQUEST_ FAILED | Request failed
| The keyword did not exist in the file DSN.
|
ODBC reserves the section name [ODBC] in which to store the connection information. The reserved keywords for this section are the same as those reserved for a connect string in SQLDriverConnect (for more information, see the SQLDriverConnect function description).
Applications may use these reserved keywords to read the information in a File DSN. If an applications wants to find out the DSN-less connection string associated with a File DSN, it can call SQLReadFileDSN for any of the reserved connection string keywords in the [ODBC] section. The full connection string passed in a DSN-less connection is a combination of all of the keywords (reserved and driver-specific) in the [ODBC] section.
Related Functions
For information about
| See
|
Writing information to a File DSNs | SQLWriteFileDSN
|