DataDirect Connect for ODBC User's Guide and Reference

void ODBC_GetTypeInfo(SQLHANDLE hstmt, SQLSMALLINT dataType)
{
RETCODE rc;
// There are 19 columns returned by SQLGetTypeInfo.
// This example displays the first 3.
// Check the ODBC 3.x specification for more information.
// Variables to hold the data from each column
char typeName[30];
short sqlDataType;
unsigned long columnSize;
SQLINTEGER strlenTypeName,
strlenSqlDataType,
strlenColumnSize;
rc = SQLGetTypeInfo(hstmt, dataType);
if (rc == SQL_SUCCESS) {
// Bind the columns returned by the SQLGetTypeInfo result set.
rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &typeName,
(SDWORD)sizeof(typeName), &strlenTypeName);
rc = SQLBindCol(hstmt, 2, SQL_C_SHORT, &sqlDataType,
(SDWORD)sizeof(sqlDataType), &strlenSqlDataType);
rc = SQLBindCol(hstmt, 3, SQL_C_LONG, &columnSize,
(SDWORD)sizeof(columnSize), &strlenColumnSize);
// Print column headings
printf ("TypeName DataType ColumnSize\n");
printf ("-------------------- ---------- ----------\n");
do {
// Fetch the results from executing SQLGetTypeInfo
rc = SQLFetch(hstmt);
if (rc == SQL_ERROR) {
// Procedure to retrieve errors from the SQLGetTypeInfo function
ODBC_GetDiagRec(SQL_HANDLE_STMT, hstmt);
break;
}