VC下的ADO编程入门(2-4)(4)
if(SUCCEEDED(hr)) fields->Release();
m_pRecordset->get_adoEOF(&valEof);
while(true)
{
if(valEof)break;
m_pRecordset->Fields->get_Item(varCounter,&field);
field->get_Value(&varValue);
strValue=VariantToString(varValue);
m_list.InsertItem(RowCount,strValue);
for(i=1;i<ColCount;i++)
{
varCounter.lVal =i;
m_pRecordset->Fields->get_Item(varCounter,&field);
field->get_Value(&varValue);
strValue=VariantToString(varValue);
m_list.SetItemText(RowCount,i,(LPCTSTR)strValue);
}
RowCount++;
m_pRecordset->MoveNext();
m_pRecordset->get_adoEOF(&valEof);
varCounter.lVal=0;
}
m_pRecordset->Close();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE(" Code=%08lx ", e.Error);
TRACE(" Code meaning = %s ", e.ErrorMessage);
TRACE(" Source = %s ", (LPCTSTR)bstrSource);
TRACE(" Description = %s ", (LPCTSTR)bstrDescription);
}
catch(...)
{
- 上一篇:VC快捷键:
- 下一篇:VC下的ADO编程入门(2-3)