我在vc++6.0中用ado连接oracle9i数据库,主要连接代码如下://导入ado库
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")//初始化com环境
::CoInitialize(NULL);_ConnectionPtr m_pConnection;try
{
m_pConnection.CreateInstance(__uuidof(Connection)); _bstr_t strConnect="Provider=OraOLEDB.Oracle.1;Data Source=test_20.20.20.3;User ID=sa;Password=lt;" m_pConnection->Open(strConnect,"","",-1);
}catch(_com_error e)
{
AfxMessageBox(e.GetErrorMessge);
}运行完m_pConnection->Open(strConnect,"","",-1)时,程序就报"未指定错误",连接不上oracle9i,以前连接oracle8i时一直是这样,都可以连上的.请教高手如何在vc中用ado连接oracle9i数据库
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")//初始化com环境
::CoInitialize(NULL);_ConnectionPtr m_pConnection;try
{
m_pConnection.CreateInstance(__uuidof(Connection)); _bstr_t strConnect="Provider=OraOLEDB.Oracle.1;Data Source=test_20.20.20.3;User ID=sa;Password=lt;" m_pConnection->Open(strConnect,"","",-1);
}catch(_com_error e)
{
AfxMessageBox(e.GetErrorMessge);
}运行完m_pConnection->Open(strConnect,"","",-1)时,程序就报"未指定错误",连接不上oracle9i,以前连接oracle8i时一直是这样,都可以连上的.请教高手如何在vc中用ado连接oracle9i数据库
要用
m_pConnection->Open(strConnect, "" , "", NULL);
{
if (m_strService.IsEmpty())
{
::MessageBox(NULL,"·þÎñÃû²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
} theApp.m_pConnection.CreateInstance(__uuidof(Connection));
try
{
//OLEDBÇý¶¯
theApp.m_strDatabase=m_strService;
CString strConn;
strConn="Provider=OraOLEDB.Oracle.1;Password=";
strConn+=m_strPassword;
strConn+=";Persist Security Info=True;User ID=";
strConn+=m_strUsername;
// strConn+=";SERVER=";
// strConn+=m_strService;
strConn+=";Data Source=";
strConn+= m_strService;
theApp.m_pConnection->Open((_bstr_t)strConn,
"",
"",
adModeUnknown);
}
catch(_com_error e)
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
return FALSE;
}
::MessageBox(NULL,"Êý¾Ý¿âÁ¬½Ó³É¹¦£¡","Ìáʾ",MB_OK);
return TRUE;}
m_pConnection->Open(strConnect,"","",NULL);
_bstr_t strConnect="Provider=OraOLEDB.Oracle.1;Data Source=test_20.20.20.3;User ID=sa;Password=lt;" m_pConnection->Open(strConnect, "sa","lt",NULL);这样不行吗?