VS 2010 MFC:debug error!
最近在学习用MFC设计一个登陆界面,MFC连接ACCESS数据库部分滴代码如下:
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance(_uuidof(Connection));
if(SUCCEEDED(hr))
{
m_pConnection->ConnectionString="File Name=mydata.dul";
m_pConnection->ConnectionTimeout=20;
hr=m_pConnection->Open("","","",adConnectUnspecified);
if(FAILED(hr))
{
AfxMessageBox(_T("open fail!"));
}
else
{
AfxMessageBox(_T("createinstance of Connection faile!"));
}
}
}
catch( _com_error e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
AfxMessageBox(bstrSource+bstrDescription);
}
用户输入:用户名与密码部分的代码如下:
UpdateData(TRUE);
CString strsql;
_RecordsetPtr m_pRecordset;
strsql.Format (_T("select * from user where name= ")+login_name+_T("AND name= ")+login_pwd);
m_pRecordset->Open (_variant_t(strsql),m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(m_pRecordset->GetRecordCount()==0)
{
MessageBox(_T("用户名或密码错误!"));
CDialogEx::OnOK();
}
else
{
MessageBox(_T("登录成功!"));
CDialogEx::OnOK();
}
}
每次运行都会出现如下错误: