BOOL CConnOracleApp::InitInstance()
{
AfxEnableControlContainer();
AfxOleInit();
HRESULT hr;
_ConnectionPtr m_pConnection; //CString strConn="provider=oraoledb.Oracle;Data Source=oracle;User id=system;Password=Manager;"
CString strConnection = "Provider=oraOLEDB.Oracle;Data Source=oracle;User ID=zxjsz; Password=zxjsz";
try{
hr =m_pConnection.CreateInstance("ADODB.Connection");
if(SUCCEEDED(hr))
{
hr=m_pConnection->Open((_bstr_t)strConnection,"","",-1);
}
}
catch(_com_error e)
{
// CCommon common;
// AfxMessageBox(common.DisplayAdoError(m_pConnTemp));
AfxMessageBox(
e.ErrorMessage());
} CConnOracleDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return FALSE;
}
我在stdafx.h文件中也加入了#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
语句,可总是提示“未指定的错误”