主题:用ADO远程连Oracle,同样的代码在ActiveX就能连上,为什么放在MFC应用程序里就不行呢?
HRESULT hr1,hr2,hr3;
_ConnectionPtr m_pConnection;
hr1=m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->CursorLocation=adUseClient;
if(!SUCCEEDED(hr1))
return;
try
{
hr1=m_pConnection->Open(
_bstr_t(L"Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521))(CONNECT_DATA=(SID=tjrd)));User ID=www;Password=www"),"","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
_ConnectionPtr m_pConnection;
hr1=m_pConnection.CreateInstance(__uuidof(Connection));
m_pConnection->CursorLocation=adUseClient;
if(!SUCCEEDED(hr1))
return;
try
{
hr1=m_pConnection->Open(
_bstr_t(L"Provider=OraOLEDB.Oracle.1;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521))(CONNECT_DATA=(SID=tjrd)));User ID=www;Password=www"),"","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}