荆樵_435 发表于 2015-9-30 10:16:53

objectARX怎么样连接oracle数据库啊?

objectARX连接oracle数据库的方法跟MFC连接数据库的方法一样吗?在MFC里面,我用下面的代码就连上了,在arx里面就连不上了!请大神指导一下!
_ConnectionPtr m_pConnection;         _RecordsetPtr m_pRecordset;
        try
        {
                //CString errormessage;
                m_pConnection.CreateInstance(__uuidof(Connection));   
                m_pConnection->Open("Provider=OraOLEDB.Oracle.1;Password=ren;User ID=ren;Data Source=ORCL;Persist Security Info=True","","",adModeUnknown);
        }   
        catch(_com_error e)
        {   
                CString errormessage;
                errormessage.Format(L"数据库连接失败!\r\n错误信息:%s", e.ErrorMessage());   
                AfxMessageBox(errormessage);    //return FALSE;
        }



http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 荆樵_435的微博

荆樵_435 发表于 2015-9-30 10:42:08

自己先顶一下!

荆樵_435 发表于 2015-9-30 14:30:56

提示错误为“没有找到提供的程序,改程序可能没有正确安装”!
但是我用MFC确实可以连上的啊!

荆樵_435 发表于 2015-10-1 09:27:42

每次都中断在这里:inline HRESULT Connection15::Open ( _bstr_t ConnectionString, _bstr_t UserID, _bstr_t Password, long Options ) {
    HRESULT _hr = raw_Open(ConnectionString, UserID, Password, Options);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _hr;
}
我的open语句是CString open;
                open.Format(_T("Provider=OraOLEDB.Oracle.1;Data Source=orcl;User ID=ren;Password=ren;Persist Security Info=True"));
                //_bstr_t strConnect="Provider=OraOLEDB.Oracle;Data Source=ORCL;User ID=ren;Password=ren;";

                HRESULT hr =m_pConnection.CreateInstance(__uuidof(Connection));
                if(FAILED(hr))
                {
                        AfxMessageBox(L"连接失败");//
                        return;
                }
                m_pConnection->Open((_bstr_t)open,"","",adModeUnknown);

LIULISHENG 发表于 2017-9-26 11:14:40

同求一下支持
页: [1]
查看完整版本: objectARX怎么样连接oracle数据库啊?