Article ID: 123652
Article Last Modified on 11/21/2006
recordset.Edit(); recordset.Field1String="SomeText"; recordset.Update();
case CFieldExchange::MarkForUpdate:
{
if (value.IsEmpty())
pFX->m_prs->SetFieldFlags(nField,
AFX_SQL_FIELD_FLAG_NULL, pFX->m_nFieldType);
else
pFX->m_prs->ClearFieldFlags(nField,
AFX_SQL_FIELD_FLAG_NULL, pFX->m_nFieldType);
...
This code was removed in Visual C++ version 2.0. The code checks to see if
a CString is empty and sets or resets the null flag accordingly. Without
this code, the null flag for a field will remain set even though you may
change the contents of a CString field variable. Because this code is no
longer present in the Visual C++ version 2.0 database classes code, you
will have to set or reset the null flag for a text field in your code.
*****
BOOL AFXAPI AfxFieldText(CDataExchange* pDX, int nIDC, void* pv,
CRecordset* pRecordset)
{
ASSERT_VALID(pRecordset);
HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
char szT[2];
if (pDX->m_bSaveAndValidate)
{
::GetWindowText(hWndCtrl, szT, sizeof(szT));
if (szT[0] == '\0')
{
if (pRecordset->IsFieldNullable(pv))
{
pRecordset->SetFieldNull(pv);
return TRUE;
}
}
else
pRecordset->SetFieldNull(pv, FALSE);
}
else
{
if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(pv))
{
szT[0] = '\0';
AfxSetWindowText(hWndCtrl, szT);
return TRUE;
}
}
return FALSE;
}
*****
You can see how the null flag for the field is set or reset. You can write
similar code to handle setting or resetting the null flag in your code.
MFC Technote #43 - "RFX Routines"
MFC Encyclopedia articles on RFX in the online books
Additional query words: 2.00 3.00
Keywords: kbbug kbdatabase kbfix KB123652