Hi, Anybody
I have a hardly question that take me a lot of time. I have a Null is
able field which may have a NULL value, I hope can update this field when it
is NULL value and I look a lot of example include the MSDN provided, but no
answer can do it. In the ADO VC++ when update a field value which current is
null Value with a non_null value, it not responds error but also not make
any updating(if current have a non_null value then updating is success).
following the MSDN: PRB: MFC DB Classes Don't Update NULL Field Values to
Non-NULL,said CRecordSet before version 2.0 there are the same problem, If
whether ADO also have the same question? I don't know? would you like give
me more instruction about null field updating?
Thank you anyway,
Bill Sun
The code is:
m_strConnection = _T("Provider=MSDASQL.1;Persist Security
Info=False;User ID=sa;Data Source=LocalServer;Initial
Catalog=pubs");
m_strCmdText = _T("test");
m_pRs->CursorLocation = adUseClient;
m_pRs->LockType = adLockOptimistic;
m_pRs->Open((LPCTSTR)m_strCmdText, (LPCTSTR)m_strConnection,
adOpenStatic,
adLockOptimistic, adCmdTableDirect);
if (FAILED(hr = m_pRs->QueryInterface(__uuidof(IADORecordBinding),
(LPVOID *) &piAdoRecordBinding)))
_com_issue_error(hr);
if (FAILED(hr = piAdoRecordBinding->BindToRecordset(this)))
_com_issue_error(hr);
....
strcpy(m_szau_fname,m_strDlgau_fname);
m_pRs->Fields->GetItem("au_fname")->Value=(_bstr_t) m_szau_fname;
piAdoRecordBinding->Update(this);
m_pRs->UpdateBatch(adAffectAll);