Created
August 14, 2019 11:07
-
-
Save tk3/d407bb2edb31fc4bb6b56c12f8ced070 to your computer and use it in GitHub Desktop.
SQLDataSources sample - unixODBC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sql.h> | |
#include <sqlext.h> | |
int main() { | |
SQLHENV henv; | |
SQLRETURN r; | |
SQLCHAR dsn_name[256]; | |
SQLSMALLINT dsn_name_len; | |
SQLCHAR driver_desc[256]; | |
SQLSMALLINT driver_desc_len; | |
SQLUSMALLINT direction; | |
r = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); | |
r = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void *)SQL_OV_ODBC3, 0); | |
printf("Data Source\n"); | |
direction = SQL_FETCH_FIRST; | |
r = SQLDataSources(henv, direction, dsn_name, sizeof(dsn_name), &dsn_name_len, | |
driver_desc, sizeof(driver_desc), &driver_desc_len); | |
while (SQL_SUCCEEDED(r)) { | |
printf(" name: %.*s\n", dsn_name_len, dsn_name); | |
printf(" description: %.*s\n", driver_desc_len, driver_desc); | |
printf("\n"); | |
direction = SQL_FETCH_NEXT; | |
r = SQLDataSources(henv, direction, dsn_name, sizeof(dsn_name), | |
&dsn_name_len, driver_desc, sizeof(driver_desc), | |
&driver_desc_len); | |
} | |
SQLFreeHandle(SQL_HANDLE_ENV, henv); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment