Microsoft KB Archive/135666

= FIX: Assertion Failure in CFieldExchange::GetColumnType =

Article ID: 135666

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q135666

<div class="symptoms_section">

SYMPTOMS
Using the MFC database classes with the Microsoft SQL Server ODBC driver versions 2.50.0121 or 2.50.0126 may cause an assertion failure after a call to SQLNumResultCols in the CFieldExchange::GetColumnType function.

<div class="cause_section">

CAUSE
This error is caused by a bug in the ODBC driver that is exposed when the cursor library is used, and happens after calling CRecordset::Requery and then trying to edit more than one record.

The following code in Dbrfx.cpp produces the assertion: SWORD nResultColumns; AFX_SQL_ASYNC(m_prs,               ::SQLNumResultCols(m_prs->m_hstmt, &nResultColumns)); ASSERT(nColumn >= 1 && (long)nColumn <= (long)nResultColumns);
 * 1) ifdef _DEBUG
 * 1) endif //_DEBUG
 * SQLNumResultCols returns 0 in nResultColumns, which causes an assertion on the next line. This is due to a bug in the driver which sets the number of columns in the result set to 0. The subsequent call to ::SQLDescribeCol will also fail with SQL State S1002 "Invalid Column number" regardless of the column number specified.

<div class="resolution_section">

RESOLUTION
To work around this problem, use a dynaset instead of a snapshot or get the 2.65.0240 version of the SQL Server driver that is included with Visual C++ 5.0.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug with the ODBC 2.5 components. This bug has been fixed in the 2.65.0240 version of the SQL Server driver that is included with Visual C++ 5.0.

Additional query words: kbVC400bug DBRFX.CPP line 2185 line 2231

Keywords: kbbug kbdatabase kbfix kbvc500fix KB135666

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.