ADO如何连接远程的Oracle数据库?连接语句怎么写?(不要通过ODBC连接,不建立dsn?)

解决方案 »

  1.   

    CString strMsg;
    CString strSQL;
    CString strDesc;
    int iCNT=0; Cn.CreateInstance(_uuidof(Connection)); //初始化Connection指针
    Rs.CreateInstance(_uuidof(Recordset)); //初始化Recordset指针ReTry:
    try
    {
    strSQL="Provider=MSDAORA.1;Password=";
    strSQL+=g_strPWD;
    strSQL+=";User ID=";
    strSQL+=g_strUID;
    strSQL+=";Data Source=";
    strSQL+=g_strServer;
    strSQL+=";Persist Security Info=True";

    BSTR bstrSQL = strSQL.AllocSysString();
    Cn->Open(bstrSQL,"","",0);
    if (Cn->GetState()==1)
    {
    return TRUE;
    }
    else
    {
    strDesc="连接数据库失败"; MessageBox(strDesc,"错误",MB_OK|MB_ICONSTOP);
    return FALSE;
    }
    }
    catch(_com_error e)
    {
    strDesc="连接数据库失败"; strMsg.Format("连接数据库失败。\n\r错误信息:\n\r%s",e.ErrorMessage());
    MessageBox(strMsg,"错误",MB_OK|MB_ICONSTOP); }
      

  2.   

    谢谢上面两位,顺便到
    http://expert.csdn.net/Expert/topic/1418/1418988.xml?temp=.8791468看看,明天结贴。