adosql.m_pConnection->Execute(_bstr_t(Delete), NULL, adExecuteNoRecords);用_bstr_t 将字符串转换一下

解决方案 »

  1.   

    楼主使用了try catch,看看捕获到的错误信息是啥
      

  2.   

    把最后的adosql.ExitConnect();这句删除就可以了~我已经试过了~没有问题
    以下是我的连接语句,不知道ExitConnect()有什么问题 会导致上面的语句出错~我的添加 查找功能也用了同样的功能 却没有报错 添加查找功能里我用到了
    adosql.m_pRecordset->PutCollect("Snumber",_variant_t(m_sNumber));这样的语句,不知道是否与此有关~~求解答~~
    void Adosql::OnInitADOConn()
    {
    ::CoInitialize(NULL);
    try
    {
    m_pConnection.CreateInstance("ADODB.Connection");
    _bstr_t strConnect="Provider=MSDASQL.1;Persist Security Info=False;Data Source=college;Initial Catalog=college";
    //strConnect是以"Microsoft OLE DB Provider for ODBC Drivers"提供程序打开名为"college"的数据库 连接字串
    m_pConnection->Open(strConnect,"","",adModeUnknown);
    AfxMessageBox("连接成功");
    }
    catch(_com_error e)
    {
    AfxMessageBox("连接失败");
    }
    }
    void Adosql::ExitConnect()
    {
    if(m_pRecordset!=NULL)
    m_pRecordset->Close();
    m_pConnection->Close();
    CoUninitialize();
    }
      

  3.   

    没有捕捉到错误信息,走的是太try里面的内容,可以修改、删除,是修改、删除执行完后出现运行错误
    Runtime error!
    This application has requested the runtime to end it in an unusual way. Medical staff with program support team for more information.
      

  4.   

    楼主,我也遇见了同样的问题,如果你解决了能不能把你的程序给我看下,[email protected]谢谢了!