我用vs2008编写c++程序,我的程序定义_ConnectionPtr pConn;没有错
一添加pConn.CreateInstance(__uuidof(Connection))能通过编译,但运行错误
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
不知道怎么办,跪求解决啊

解决方案 »

  1.   

    加异常捕获看是什么错误
    try
    {
    //你的ADO代码
    }
    catch (_com_error& e)
    {
    CString strMsg;
    strMsg.Format(_T("错误描述:%s\n错误消息%s", 
    (LPCTSTR)e.Description(),
    (LPCTSTR)e.ErrorMessage());
    AfxMessageBox(strMsg);
    }
      

  2.   

    HRESULT hr = pConnection.CreateInstance(__uuidof(Connection));
    if (FAILED(hr))
    {
    _com_error e(hr);
    AfxMessageBox(e.ErrorMessage());
    return;
    }
    测试下CreateInstance返回值,看是否创建成功。
      

  3.   

    http://andylin02.iteye.com/blog/706713