FIX: Assertion Occurs When Calling BeginTrans()Last reviewed: September 18, 1997Article ID: Q112756 |
1.50
WINDOWS
kbprg kbfixlist kbbuglist
The information in this article applies to:
The Microsoft Foundation Classes (MFC), included with: - Microsoft Visual C++ for Windows, version 1.5
SYMPTOMSIf CDatabase::BeginTrans() is called a second time for a CDatabase object and the debug version of the Microsoft Foundation Class (MFC) Library is used, the following assertion will occur:
File dbcore.cpp, Line 549, Assertion Failed!The message is displayed in a message box. When running under the debugger, the message is also displayed in the Output window. This problem occurs even though CDatabase::CommitTrans() was called after the first CDatabase::BeginTrans() call.
CAUSEThe CDatabase class uses a variable called "m_bTransactionPending" for debug mode, which gets set to TRUE in CDatabase::BeginTrans() with the following code:
#ifdef _DEBUG m_bTransactionPending = TRUE; #endif // _DEBUGThe m_bTransactionPending variable should be assigned FALSE (but is not) in the CDatabase::CommitTrans() function. Here is the code:
#ifdef DEBUG m_bTransactionPending = FALSE; #endif // DEBUGNote that "DEBUG:" was used rather than "_DEBUG". This is a bug that occurs only when using the debug version of the Microsoft Foundation Class Library.
RESOLUTIONModify the code in CommitTrans() by changing the DEBUG constant to _DEBUG, and rebuild the MFC library by following the directions in the README.TXT located in the \MSVC\MFC\SRC directory. As an alternative, you could copy the code from CommitTrans() into a new member function of a CDatabase-derived class, fix the code, and call the new function instead of CommitTrans(). However, if you're letting CRecordset create the database object (that is, not passing a pointer to a CDatabase object into the constructor), CDatabase will be used instead of your CDatabase-derived class.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft Foundation Class Library version 2.5. This bug was corrected in Visual C++ for Windows, version 1.51 (MFC 2.51).
|
Additional reference words: 1.50 2.50 Transaction
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |