出错如下:
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")怎么回事?如何解决?谢谢

解决方案 »

  1.   

    你先单步调试,看出错在哪一行,否则不好说,好多地方都可能出错,你用的是debug版吗,调试的时候要用debug版。
    另外,你用ADO,居然不catch错误,你加上错误catch吧,你上面的错误还不知道是不是ADO的错误呢。
      

  2.   

    先单步执行。

    ((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
    (_bstr_t)pRst->GetCollect("NAME"));
    把NAME换个名试试
      

  3.   

    你不try ,怎么跟踪那里出错呀。。给你改写下:
    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跟踪哟。后面自己跟踪解决下。应该问题不大。
      

  4.   

    今我在网上找了一个例子,也是ADO调用ACCESS,也出现这个对话框.是不是我机器里少甚么东西啊?
      

  5.   

    VC的ADO数据库查询与增删改操作实例,看完后你就知道了:http://www.maoyeah.com/display.asp?boardid=3&id=43
      

  6.   

    pConn->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\MyProject\Access\Test1.mdb"//这句肯定有问题 \\