Export (0) Print
Expand All

SQLValidDSN Function


Version Introduced: ODBC 2.0


SQLValidDSN checks the length and validity of the data source name before the name is added to the system information.

     LPCSTR    lpszDSN);


[Input] Data source name to be checked.

The function returns TRUE if the data source name is valid. It returns FALSE if the data source name is invalid or the function call failed.

When SQLValidDSN returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. A *pfErrorCode is returned only if the function call failed, not if FALSE was returned because the data source name is invalid. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.





General installer error

An error occurred for which there was no specific installer error.


Out of memory

The installer could not perform the function because of a lack of memory.

SQLValidDSN is called by a driver's ConfigDSN to check the length of the data source name and the validity of the individual characters in the data source name. It checks whether the length of the name is greater than SQL_MAX_DSN_LENGTH, as defined in Sqlext.h. (The length of the data source name is also checked by SQLWriteDSNToIni.) SQLValidDSN checks whether any of the following invalid characters are included in the data source name:

[ ] { } ( ) , ; ? * = ! @ \

For information about


Adding, modifying, or removing a data source

ConfigDSN (in the Setup DLL)

Adding, modifying, or removing a data source


Writing a data source name to the system information


© 2014 Microsoft