vc ado mssql 修改字段的值报错
如题,检测数据中字段值为NULL的字段,如果检测到将其值修改为“空”,但是却抛出异常:Unknow error 0x800A0CC1,以下是代码:
//获取表的列数
long columnNum = tacApp->m_pRst->Fields->Count;
for(long i=0; i<columnNum; i++)
{
CString strName=(char*)_bstr_t(tacApp->m_pRst->Fields->Item[i]->Name);
m_strCombo.AddString(strName);
}
//////////////////////////////////////////////////////////////////////////20090521
//获取数据库表lift中的字段数和各字段名
_variant_t colName;
for(int colNum=0; colNum<columnNum; colNum++)
{
tacApp->m_pRst->MoveFirst();
while(!tacApp->m_pRst->adoEOF)
{
colName = tacApp->m_pRst->GetCollect(_variant_t((long)colNum));
if(colName.vt == VT_NULL)
{
try
{
tacApp->m_pRst->PutCollect(_variant_t(colName), _variant_t("空")); //
}
catch(_com_error &e)
{
CString strPut;
strPut.Format("PutCollect: %s.", e.ErrorMessage());
MessageBox(strPut);
}
}
tacApp->m_pRst->MoveNext();
}
//strColName[colNum] = (char*)_bstr_t(tacApp->m_pRst->Fields->Item[colNum]->Name);
}