ADO程序运行出现Runtime Error
ADO程序运行总是出现这种错误:Runtime Error! This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
代码如下:
void CAdoDlg::OnBtnQuery()
{
// TOD Add your control notification handler code here
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
pConn->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=maofeng;Initial Catalog=pubs;Data Source=MAOFENG\\\\MF_SQL";
pConn->Open("","","",adAsyncConnect);
pRst=pConn->Execute("select * from authors",NULL,adCmdText);
while(!pRst->rsEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("au_lname"));
pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
}
编译没问题!!!
经调试,发现错在pRst=pConn->Execute("select * from authors",NULL,adCmdText);这一句。
注:SQL(MAOFENG\MF_SQL)已打开,数据库登录没问题,访问权限没问题。
大家帮忙看一下呀,谢谢,十分感谢,急呀,急呀,急呀!!