举手之劳,不胜感激!!!!!!!!!
我用的ADO对象编程访问数据库,我想根据number一项查询,但用标示的循环只能查询前两个,为什么???谢谢
void CAdoDll::OnSearch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int curSel=m_list.GetCurSel();
_variant_t va;
if(curSel<0) return;
m_pRecordset->MoveFirst();
m_pRecordset->Move(long(curSel));
va=m_pRecordset->GetCollect("number");
try
{
if(m_no!=(LPCSTR)_bstr_t(va))
{
m_pRecordset->MoveNext();
m_pRecordset->Move(long(curSel));
va=m_pRecordset->GetCollect("number");
}
if(va.vt!=VT_NULL)
m_no=(LPCSTR)_bstr_t(va);
va=m_pRecordset->GetCollect("name");
if(va.vt!=VT_NULL)
m_name=(LPCSTR)_bstr_t(va);
va=m_pRecordset->GetCollect("department");
if(va.vt!=VT_NULL)
m_bumen=(LPCSTR)_bstr_t(va);
va=m_pRecordset->GetCollect("salary");//m_gongzi
//va.ChangeType(VT_I4,NULL); //V_I4 对应long型
//m_gongzi=V_I4(&va);
m_gongzi=(short)(va);
UpdateData(false);
}
catch(_com_error * e)
{AfxMessageBox(e->ErrorMessage());}
}