Article ID: 155721
Article Last Modified on 11/21/2006
m_myTime = CTime::GetCurrentTime();
Call CRecordset::AddNew() on an empty recordset, set the value of the
Ctime member variable, and then call CRecordset::Update().
The insert to the database works; however, an access violation may occur
before the call to Update() returns.
void AFXAPI RFX_Date(CFieldExchange* pFX, LPCTSTR szName, CTime&
value)
{
...
switch (pFX->m_nOperation)
{
....
case CFieldExchange::LoadField:
{
...
pts->year = (SWORD)value.GetYear();
...
}
...
}
_AFX_INLINE int CTime::GetYear() const
{ return (GetLocalTm(NULL)->tm_year) + 1900; }
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: kbbug kbcode kberrmsg kbfix kbvc500fix KB155721