Hi, guys,
For some reason this code above fails for SQLColAttribute().
The value of the count is 29 and the value of i is 51 and the error is "Invalid descriptor index", which according to the MSDN means "column is out of bounds".
I am trying to connect to MS SQL Server 10.0 from MSVC 2017 on Windows 8.1. It is for "INFORMATION_SCHEMA.ROUTINES" table. Server is running on the same machine.
Can anyone please explain this?
Thank you.
Code:
for( int count = 0; count < i; count++ )
{
ret = SQLColAttribute( stmt_col, (SQLUSMALLINT ) count + 1, SQL_DESC_AUTO_UNIQUE_VALUE, NULL, 0, NULL, &autoincrement );
if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
{
GetErrorMessage( errorMsg, 1, stmt_col );
result = 1;
SQLFreeHandle( SQL_HANDLE_STMT, stmt_col );
stmt_col = 0;
SQLDisconnect( hdbc_col );
SQLFreeHandle( SQL_HANDLE_DBC, hdbc_col );
}
else
{
if( autoincrement )
{
ret = SQLColAttribute( stmt_col, (SQLUSMALLINT ) count + 1, SQL_DESC_BASE_COLUMN_NAME, NULL, 0, NULL, &autoincrement );
if( ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO )
{
GetErrorMessage( errorMsg, 1, stmt_col );
result = 1;
SQLFreeHandle( SQL_HANDLE_STMT, stmt_col );
stmt_col = 0;
SQLDisconnect( hdbc_col );
SQLFreeHandle( SQL_HANDLE_DBC, hdbc_col );
}
else
autoinc_fields.push_back( fieldName );
}
}
}
}
The value of the count is 29 and the value of i is 51 and the error is "Invalid descriptor index", which according to the MSDN means "column is out of bounds".
I am trying to connect to MS SQL Server 10.0 from MSVC 2017 on Windows 8.1. It is for "INFORMATION_SCHEMA.ROUTINES" table. Server is running on the same machine.
Can anyone please explain this?
Thank you.