ADO连接如何知道用户名是否正确,用户名正确的话,又如何知道密码是否正确(数据库为ORACLE,SQL SERVER).
我要做在输入正确用户名和密码才能连接ADO,怎么做?

解决方案 »

  1.   

    try
    {
      pConn->Open(...);
    }
    catch(_com_error &e)
    {
      _bstr_t bstrSQLState(GetSQLState(m_pConnection));
      //或者查看pConn->Errors[0]
    }http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/oledberrors.asp
      

  2.   

    怎么描述呀,哪里有全部ADO错误代码?
      

  3.   

    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);
    }