CDatabase m_database;
CString username;
CString password;
CString id;
m_database.Open(NULL,FALSE,FALSE,_T("ODBC;Dsn=student;server=localhost;uid=;pwd="));
CString strSQL;  
strSQL.Format ("select * from  user_pass where username='%s'and password='%s' and id='%s' ",m_username,m_password,m_id);
int len = m_ListTeacher.GetHeaderCtrl()->GetItemCount();
try{
m_pSet->MoveFirst();
int nItem=m_ListTeacher.GetItemCount ();

while (!m_pSet->IsEOF())
{
    username=m_pSet->m_username1;
password=m_pSet->m_password1;
id=m_pSet->m_id1; m_ListTeacher.InsertItem(nItem,"");
    m_ListTeacher.SetItemText(nItem,2,username);
        m_ListTeacher.SetItemText(nItem,1,password);
        m_ListTeacher.SetItemText(nItem,0,id);
m_pSet->MoveNext();
nItem ++; }
}
catch(_com_error e)
 {
  AfxMessageBox("表中存在记录为空!");
  return;
 }
 m_pSet->Close();//关闭记录  
 

}
5
void CMy222Dlg::OnButton2() 
{
// TODO: Add your control notification handler code here
CDatabase m_database;
CLoginSet* m_recordset=new CLoginSet (&m_database);
CString strSQL;
UpdateData(TRUE);
strSQL.Format ("select * from  user_pass where username='%s'and password='%s' ",m_username,m_password);
m_recordset->Open (AFX_DB_USE_DEFAULT_TYPE,strSQL);
if(m_recordset->GetRecordCount()==0)
MessageBox("密码错误",NULL,MB_OK);
else
MessageBox("登陆成功",NULL,MB_OK);
大家看看错在哪?标题的意思是? 本人新手刚接触数据库不久
求人心热解答