BUG: Error in Requery When Set Null Date Parameter to Not NullID: Q166756
|
When you set a previously Null date parameter to no longer be Null, using either CRecordset::SetParamNull() or CRecordset::SetFieldNull(), it may cause a subsequent call to CRecordset::Requery() to generate the following exception:
Invalid string or buffer length
During a call to CRecordset::Open, no memory is allocated for a Null date field. However, CRecordset::Requery expects the memory to exist.
Create a replacement for the RFX_Date function which always allocates memory for the date field. See the MORE INFORMATION section.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
This problem only occurs with the version of RFX_Date that takes a CTime argument.
CMySet rs;
try
{
rs.SetParamNull( 0, TRUE );
rs.Open( CRecordset::snapshot, "{Call Query1(?)}" );
rs.m_paramDate = CTime( 1996, 10, 13, 0, 0, 0 );
rs.SetParamNull( 0, FALSE );
rs.Requery();
}
catch( CDBException* e )
{
AfxMessageBox( e->m_strError );
e->Delete();
}
rs.Close();
#include "stdafx.h"
at the top of your new .cpp file, and include the .cpp file in your
project.
if (pFX->m_prs->IsParamStatusNull(nField - 1))
{
pts = NULL;
*plLength = SQL_NULL_DATA;
}
else
if( CFieldExchange::BindParam != pFX->m_nOperation ) {
RFX_Date(pFX, szName, value);
return;
}
Additional query words: kbVC500bug kbVC600bug kbmfc kbdatabase kbodbc
Keywords : kbVC500bug kbVC600bug
Version : 5.0,6.0
Platform : NT WINDOWS
Issue type :
Last Reviewed: July 30, 1999