出错如下:
Runtime Error!This application has requested the Runtime to terminate it in unusual way.Please contact the application's support team for more information.
我的代码:
void CADOTest5Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CoInitialize(NULL); _ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset)); pConn->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\MyProject\Access\Test1.mdb"
pConn->Open("","","",-1);
pRst=pConn->Execute("select * from Table1",NULL,adCmdText); while(!pRst->adoEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("NAME")); pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
}
我的import语句:
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "adoEOF")怎么回事?如何解决?谢谢
Runtime Error!This application has requested the Runtime to terminate it in unusual way.Please contact the application's support team for more information.
我的代码:
void CADOTest5Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CoInitialize(NULL); _ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset)); pConn->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\MyProject\Access\Test1.mdb"
pConn->Open("","","",-1);
pRst=pConn->Execute("select * from Table1",NULL,adCmdText); while(!pRst->adoEOF)
{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("NAME")); pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
}
我的import语句:
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "adoEOF")怎么回事?如何解决?谢谢
另外,你用ADO,居然不catch错误,你加上错误catch吧,你上面的错误还不知道是不是ADO的错误呢。
或
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("NAME"));
把NAME换个名试试
CoInitialize(NULL);
try
{
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));pConn->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\MyProject\Access\Test1.mdb"
pConn->Open("","","",-1);
}
catch(_com_err e)
{
//把 错误信息显示出来:return;
}pRst=pConn->Execute("select * from Table1",NULL,adCmdText);//这句话问题也大。connection 写法搞的象vb。在vc里用com东西要多try跟踪哟。后面自己跟踪解决下。应该问题不大。