SQLDataSources Function
When SQLDataSources returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_ENV and a Handle of EnvironmentHandle. The following table lists the SQLSTATE values typically returned by SQLDataSources and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.
|
SQLSTATE |
Error |
Description |
|---|---|---|
|
01000 |
General warning |
(DM) Driver Manager–specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.) |
|
01004 |
String data, right truncated |
(DM) The buffer *ServerName was not large enough to return the complete data source name. Therefore, the name was truncated. The length of the entire data source name is returned in *NameLength1Ptr. (Function returns SQL_SUCCESS_WITH_INFO.) (DM) The buffer *Description was not large enough to return the complete driver description. Therefore, the description was truncated. The length of the untruncated data source description is returned in *NameLength2Ptr. (Function returns SQL_SUCCESS_WITH_INFO.) |
|
HY000 |
General error |
(DM) An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause. |
|
HY001 |
Memory allocation error |
(DM) The Driver Manager was unable to allocate memory that is required to support execution or completion of the function. |
|
HY010 |
Function sequence error |
(DM) SQLExecute, SQLExecDirect, or SQLMoreResults was called for the StatementHandle and returned SQL_PARAM_DATA_AVAILABLE. This function was called before data was retrieved for all streamed parameters. |
|
HY013 |
Memory management error |
The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions. |
|
HY090 |
Invalid string or buffer length |
(DM) The value specified for argument BufferLength1 was less than 0. (DM) The value specified for argument BufferLength2 was less than 0. |
|
HY103 |
Invalid retrieval code |
(DM) The value specified for the argument Direction was not equal to SQL_FETCH_FIRST, SQL_FETCH_FIRST_USER, SQL_FETCH_FIRST_SYSTEM, or SQL_FETCH_NEXT. |
|
HY117 |
Connection is suspended due to unknown transaction state. Only disconnect and read-only functions are allowed. |
(DM) For more information about suspended state, see SQLEndTran Function. |
Because SQLDataSources is implemented in the Driver Manager, it is supported for all drivers regardless of a particular driver's standards compliance.
An application can call SQLDataSources multiple times to retrieve all data source names. The Driver Manager retrieves this information from the system information. When there are no more data source names, the Driver Manager returns SQL_NO_DATA. If SQLDataSources is called with SQL_FETCH_NEXT immediately after it returns SQL_NO_DATA, it will return the first data source name. For information about how an application uses the information returned by SQLDataSources, see Choosing a Data Source or Driver.
If SQL_FETCH_NEXT is passed to SQLDataSources the very first time it is called, it will return the first data source name.
The driver determines how data source names are mapped to actual data sources.