Conformance
Version Introduced: ODBC 3.0
Summary
SQLReadFileDSN reads information from a File DSN.
Syntax
BOOL SQLReadFileDSN( LPCSTR lpszFileName, LPCSTR lpszAppName, LPCSTR lpszKeyName, LPSTR lpszString, WORD cbString, WORD * pcbString);
Arguments
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.
Returns
The function returns TRUE if it is successful, FALSE if it fails.
Diagnostics
When SQLReadFileDSN returns FALSE, an associated *pfErrorCode value can 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.
*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. |
Comments
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 can 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 DSN | SQLWriteFileDSN |