void CLMSDlg::OnButtonlogin() { // TODO: Add your control notification handler code here CMainsystem dlg; CADOConn adoconn; CString sqlstr,str; int countcleck; countcleck=((CComboBox*)GetDlgItem(IDC_COMBOCLECK))->GetCurSel(); ((CComboBox*)GetDlgItem(IDC_COMBOCLECK))->GetLBText(countcleck,str); UpdateData(TRUE); if(m_user.IsEmpty()) { MessageBox("用戶名不能爲空","錯誤",MB_ICONERROR); GetDlgItem(IDC_EDITUSER)->SetFocus(); } try { sqlstr.Format("select *from usertable where uusername='%s' and uuserpassword='%s' and uusercleck='%s'",m_user,m_password,str); _bstr_t vSQL; vSQL=(_bstr_t)sqlstr; _RecordsetPtr m_recordset; m_recordset=adoconn.GetRecordSet(vSQL); CString str1,str2,str3; str1=(LPCSTR)(_bstr_t)(m_recordset->GetCollect("uusername")); str2=(LPCSTR)(_bstr_t)(m_recordset->GetCollect("uuserpassword")); str3=(LPCSTR)(_bstr_t)(m_recordset->GetCollect("uusercleck")); str1.TrimRight(); str2.TrimRight(); str3.TrimRight(); if(str1==m_user || str2==m_password || str3==str) { MessageBox("恭喜你,登陸成功!","正確",MB_ICONQUESTION); this->EndDialog(1); dlg.DoModal(); } } catch(...) { MessageBox("操做失敗","錯誤",MB_ICONERROR); m_user=""; m_password=""; GetDlgItem(IDC_EDITUSER)->SetFocus(); UpdateData(false); } }