判断 connect 的 State 如果是 真 表示连上了,假 的话表达失败

解决方案 »

  1.   

    try
    {
    ...
    m_pConnection->Open (conn,"","",-1);
    }
    catch(_com_error * e)

    AfxMessageBox(e->ErrorMessage());

    catch(...)
    {
    long errorcount=m_pConnection->GetErrors ()->GetCount ();
            _bstr_t add;
    CString errormsg;
    for (short i=0;i<errorcount;i++)
    {
    add=m_pConnection->GetErrors ()->GetItem (COleVariant((short)i))->GetDescription ();
    errormsg.Insert (0,(char*)add);
    errormsg+="\r";
    }
    AfxMessageBox(errormsg);
    ExitProcess(0);
    }