FIX: ODBC Long Binary Functions Use SQL_NO_TOTAL Incorrectly

Last reviewed: September 19, 1997
Article ID: Q149137
4.00 4.10 WINDOWS NT kbprg kbfile kbbuglist kbfixlist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Edition, versions 4.0, 4.1

SYMPTOMS

Running an application built using the MFC ODBC classes from Visual C++ 4.0 or 4.1 to retrieve CLongBinary data from a database may result in data truncation. If you're using Visual C++ 4.1, the truncation is only evident in release builds; debug builds work as expected.

CAUSE

There is a programming error in the MFC code that can lead to this behavior. MFC expects SQL_NO_TOTAL to be the return code of the ::SQLGetData() ODBC API. SQL_NO_TOTAL is used by some drivers when retrieving long binary data. In reality, SQL_NO_TOTAL will be returned as a value of one of the parameters of ::SQLGetData().

As a consequence of the bug, a datasource that uses a driver that returns SQL_NO_TOTAL may experience truncation of long binary data. MFC will only call SQLGetData once rather than in a loop until all data is retrieved as is expected by ODBC.

Refer to the MFC source code (Dbrfx.cpp in Mfc\Src), and look at the do while loop in the function CFieldExchange::GetLongBinaryData() for more details.

In MFC 4.1, a fix was implemented, but it was enclosed in conditional compilation directives that only compile the code in debug builds.

RESOLUTION

A new implementation of RFX_LongBinary that avoids this defect in the MFC code is available to assist you in correcting this problem. Simply download the file as described below, run the .exe to expand the source files, and then incorporate them into your project. Replace all occurrences of RFX_LongBinary with the new RFX_LongBinary_Alloc and rebuild.

The following file is available for download from the Microsoft Software Library:

 ~ Alloc.exe

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 32- bit Edition version 4.2.


KBCategory: kbprg kbfile kbbuglist kbfixlist
KBSubcategory: MfcDatabase vcbuglist400 vcfixlist420
Additional reference words: 4.00 4.10 4.20
Keywords : MfcDatabase vcbuglist400 vcfixlist420 kbbuglist kbfile kbfixlist kbprg
Technology : kbMfc
Version : 4.00 4.10
Platform : NT WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 19, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.