关于ADO,问了好多地方了,都没人能给我个正确的答复!!!
_variant_t vUsername,vUserpsw;
_RecordsetPtr m_pRecordset;
try
{ m_pRecordset.CreateInstance("ADODB.Recordset");
CString strSql;
strSql.Format("SELECT * FROM loginuser WHERE username='%s'",strName);
////////以下2句应该为错误的地方,因为注释掉以后就没有错了
m_pRecordset->Open(_variant_t(strSql),_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
vUserpsw = m_pRecordset->GetCollect("userpsw");
//////////////////////////////////////////////////////
if (strcmp(strPsw,(LPCTSTR)(_bstr_t)vUserpsw)==0)
{CLogDlg::CreateFile();MessageBox("正在登陆");
AfxMessageBox("用户名或密码错误,请重新输入!");
}
catch (_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
请各位帮忙看看,编译没有错,运行时出错,应该怎样改呢?多谢