大家看看我这段代码错在哪里,刚学不太懂!!
void CTest2Dlg::OnOK()
{
_RecordsetPtr MySet;
UpdateData(TRUE);
try
{
m_DBCnt.CreateInstance(_uuidof(Connection));
MySet.CreateInstance(_uuidof(Recordset));
CString _sql;
_sql.Format("DSN=crystal");
_bstr_t sql=_sql;
m_DBCnt->Open(sql,"","",-1);
_sql.Format("select * from users where stu_id='%s' and stu_password='%s'",m_UserName,m_UserPassword);
_bstr_t sql2=_sql;
MySet=m_DBCnt->Execute(sql2,NULL,adCmdText);
if(MySet->GetRecordCount()==0)
{
MessageBox("login incorrect");
CDialog::OnOK();
}
else
{
MessageBox("login correct");
CDialog::OnOK();
}
}
catch(_com_error& e)
{
AfxMessageBox(e.ErrorMessage());
this->EndDialog(0);
}
if (CanExit())
CDialog::OnOK();
}
=========================================================
不知道为什么,不管你怎么输,即使没这个用户密码他都是“login correct”
还有一些其他的问题,希望各高手指教