怎么打不开记录集??纳闷
代码如下void CADO::InitADO()
{
::CoInitialize(NULL);
try
{
if (FAILED(m_pConnection.CreateInstance(__uuidof(Connection))))
{
AfxMessageBox("Create Instance failed!");
return;
}
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
//Sleep(4000);
}
调用函数:
UpdateData();
m_ado.InitADO();
CString strConnect;
strConnect.Format("Provider=SQLOLEDB.1;Persist Security Info=TRUE;UID=sa;PWD=jiaojinge;Initial Catalog=Mydbse");//
if (FAILED(m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown)))
{
AfxMessageBox("Can not open Database!");
m_pConnection.Release();
}
int id;
CString password;
CString strsql;
strsql="select Password from Stu_base_info where name=m_User";
_bstr_t bstrsql=strsql.AllocSysString();
if(FAILED(m_ado.m_pRecordset->Open(bstrsql,_variant_t((IDispatch*)m_pConnection),\ //出错
adOpenDynamic,adLockOptimistic,adCmdText)))
{
AfxMessageBox("Open table failed!");
m_ado.m_pRecordset.Release();
}
/* _variant_t RecordsAffected;
m_ado.m_pRecordset=m_pConnection->Execute("select Password from Stu_base_info where name=m_User",&RecordsAffected,adCmdText);
*/
错误提示: