请看送分的问题,搞不定呀!
这段是可以连同oracle的代码:
CString strConnection = _T("Provider=OraOLEDB.Oracle.1;Password=test2;Persist Security Info=True;User ID=test2;Data Source=orasd");
if(m_pDb.Open(strConnection))//成功了
{
。。。。。。。
}
else
{
AfxMessageBox(m_pDb.GetLastErrorString());
DWORD dwError = m_pDb.GetLastError();
return FALSE;
}
BOOL CADODatabase::Open(LPCTSTR lpstrConnection, LPCTSTR lpstrUserID, LPCTSTR lpstrPassword)
{
HRESULT hr = S_OK;
if(IsOpen())
Close();
if(strcmp(lpstrConnection, _T("")) != 0)
m_strConnection = lpstrConnection;
ASSERT(!m_strConnection.IsEmpty());
try
{
hr = m_pConnection->Open(_bstr_t(m_strConnection), _bstr_t(lpstrUserID), _bstr_t(lpstrPassword), NULL);
return hr == S_OK;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
}
这段是连通不了的代码:
_bstr_t strConnect="Provider=OraOLEDB.Oracle.1;Password=test2;Persist Security Info=True;User ID=test2;Data Source=orasd";
try{
myConnect->Open(strConnect,"","",NULL);//失败了
}
catch(_com_error &e)
{
::MessageBox(NULL,e.Description(),"警告",MB_OK ¦ MB_ICONWARNING);
}
谁能告诉我为什么呀!!!!!!!!