The information in this article applies to:
SYMPTOMSRunning an application that uses the MFC DAO classes from Visual C++ version 4.0 or 4.1 to retrieve CLongBinary data from a database may result in one or more of the following behaviors when performing a recordset move or requery: -or-
CAUSEThere is a programming error in the MFC code that can lead to this behavior: GlobalReAlloc is incorrectly used. The return value of GlobalReAlloc is not used, so the global handle embedded in the CLongBinary recordset member variable becomes invalid if GlobalReAlloc moves the virtual memory block. For more information, refer to the MFC source code in Daodfx.cpp of the Mfc\Src directory, and look at the use of GlobalReAlloc in the AllocLongBinary() function. RESOLUTIONThere are two steps to resolving this problem. Both must be performed in order to reliably work around this issue. Step 1Make certain you have caching disabled in all DFX_LongBinary function calls. Caching is disabled if there is no fifth parameter specified in the DFX_LongBinary function call or if the value of the fifth parameter is the symbol AFX_DISABLE_FIELD_CACHE or the equivalent numeric value 0. This only applies to DFX_LongBinary function calls; no other DFX function calls need to be modified.Enabling caching for long binary fields is generally unwise anyway, and can be fatal due to the GlobalReAlloc misuse. Additionally, it is not a simple matter to work around the GlobalReAlloc issue as it pertains to caching, so the best solution is to simply not use caching for long binary fields. Step 2A new implementation of DFX_LongBinary that avoids the defect in the MFC code is available to assist you in correcting this problem. Please note that this code does not fix caching for long binary fields. As Step 1 indicates, caching of long binary fields must be disabled.The following file is available for download from the Microsoft Software Library: Daoclb.exeFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base: Q119591 How to Obtain Microsoft Support Files from Online Services STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++, 32-bit Edition, version 4.2. Additional query words: kbVC400bug 4.00 4.10 4.20 softlib software library
Keywords : kbDAO kbDatabase kbMFC kbVC kbVC420fix |
Last Reviewed: July 30, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |