用ado访问access数据库,用下面的语句读取数据
criteria=(_bstr_t)(m_pRecordset->Fields->GetItem(_variant_t("sym0"))->Value);
如果碰上某条记录中该字段是空字符串,则报错。
一个个用try catch过滤太麻烦了!有没有好办法。
criteria=(_bstr_t)(m_pRecordset->Fields->GetItem(_variant_t("sym0"))->Value);
如果碰上某条记录中该字段是空字符串,则报错。
一个个用try catch过滤太麻烦了!有没有好办法。
m_pRecordset->Open(bstrSQL,(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText);
if(!m_pRecordset->adoEOF)
{
TheValue = m_pRecordset->GetCollect("lcount");
if(TheValue.vt!=VT_NULL) //加上这个判断,就可以了
{
int AllCount = TheValue.lVal;
}
}
{
CString str;
if(TheValue.vt!=VT_NULL && TheValue.vt!=VT_EMPTY)
{
str = var.bstrVal;
} return str;
}