一个ADO 访问ACCESS 数据库的有关问题,用户登陆验证的有关问题.恳请大侠帮助

一个ADO 访问ACCESS 数据库的问题,用户登陆验证的问题.恳请大侠帮助!
是这样的:
我现在要在一个对话框的OK 按钮的单击事件中实现用户的登陆时的数据验证功能.
功能要求:在一个编辑框中只要求输入用户的ID 号,在OK 的事件中实现数据的验证的功能.
我现在把OnOk中的代码贴上,请帮助我看一下问题在哪?
我现在只能实现把编辑框中数据与数据表中的第一条记录做比较.后面的记录好象得不到数据.

[size=11px]void CTestDlg::OnButtonLogin() 
{
  // TODO: Add your control notification handler code here
   
  CString strName; //声明一个存储记录的变量
  UpdateData(TRUE); //获得编辑框里的字符串

m_UserLogin.TrimLeft(); //m_UserLogin 编辑框变量
m_UserLogin.TrimRight()
  _ConnectionPtr m_pConnection;
m_pConnection.CreateInstance(__uuidof(Connection));
try
{
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=testdb.mdb","","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset)); //查询数据库,看是否有此用户和密码
  try
  {  
  m_pRecordset->Open("select * from testtop",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
   
  if(m_pRecordset->adoEOF||m_UserLogin=="") //如果没有此用户和密码
  {
  MessageBox("请输入正确的用户名和密码!","错误",MB_ICONEXCLAMATION);
  }
  else
  {  
  strName=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Name");
   
if(strName!=m_UserLogin)
MessageBox("输入的ID 不正确");
  CDialog::OnOK();
  }
  }
  catch (_com_error *e)  
  {  
AfxMessageBox(e->ErrorMessage());
  }
}
////////////////////////////上面的代码可以编译运行,如果在编辑框中输入与数据表中的第一条记录相等的数据就正常,其他的数据就不可以了.感觉游标没有向下条记录移动.
数据表中有两个字段"Name","Age". 请高手指点!

------解决方案--------------------
没看到你用了while循环,也没有MoveNext移动游标的操作,哪来的第二条记录?
------解决方案--------------------
为什么不select count(*) from testtop where 用户名=‘输入的用户名’and 密码='输入的密码',然后只要判断是否大于0就可以了
------解决方案--------------------
顶1楼,没进行循环查询哪来的向下移动?
C/C++ code

try 
{    
    m_pRecordset->Open("select * from testtop",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); 
    
    if(m_pRecordset->adoEOF | |m_UserLogin=="")     //如果没有此用户和密码 
    { 
        MessageBox("请输入正确的用户名和密码!","错误",MB_ICONEXCLAMATION); 
    } 
    else 
    {    
        while(!m_pRecordset->adoEOF)
        {
        
            strName=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Name"); 
            if (strName==m_UserLogin)break;
                
            m_pRecordset->MoveNext();
        }
        if(m_pRecordset->adoEOF) 
            MessageBox("输入的ID 不正确"); 
        CDialog::OnOK(); 
    } 
}

------解决方案--------------------
select count(*) from testtop where 用户名=‘输入的用户名’and 密码='输入的密码'.判断数据库中有数据.则表示
所输入的用户信息正确,就可以登录了.