The information in this article applies to:
SYMPTOMSAn application may fail with an access violation while executing the RFX_Date() function. A message similar to the following appears:
CAUSE
The RFX_Date() function in MFC 4.2 now requires initialization of CTime
objects. Versions of MFC earlier than 4.2 do not have this requirement.
AppWizard and ClassWizard do not initialize the CTime member variables for
you.
RESOLUTIONInitialize the CTime member variables in the constructor of your CRecordset- derived class. The following is one way to initialize the CTime member variable:
STATUSThis problem was corrected in the MFC AppWizard included with Microsoft Visual C++, version 5.0. CTime member variables are now assigned a value of zero by the AppWizard. If a CRecordset class is manually added to your project that contains an empty recordset you still need to initialize the CTime member variable as explained in the RESOLUTION section. MORE INFORMATIONHere is one common scenario where you may see an access violation: Call CRecordset::AddNew() on an empty recordset, set the value of the Ctime member variable, and then call CRecordset::Update().The following steps show how the access violation occurs:
GetLocalTm() returns the value from localtime(), which is a NULL pointer if
the CTime value is a negative number. Because CTime has not been
initialized, it may have a negative value. When GetYear() attempts to
dereference this NULL pointer, the access violation occurs in AFX.INL at
line 265.
Additional query words: crash gpf exception kbDatabase kbMFC kbVC420bug kbVC500fix kbDSupport KBDSD
Keywords : kbcode kberrmsg kbVC420bug kbVC500fix |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |