CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Aug 2002
    Posts
    756

    Weirdness with ODBC API

    Hi, guys,

    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 );
                                                }
                                            }
                                        }
                                    }
    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.
    Last edited by OneEyeMan; April 7th, 2021 at 12:16 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured