请看送分的问题,搞不定呀!

rafter263 2003-08-14 05:34:38
这段是可以连同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);
}

谁能告诉我为什么呀!!!!!!!!
...全文
37 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rafter263 2003-08-15
  • 打赏
  • 举报
回复
谢谢各位热心人,问题已经解决了!!!马上揭帖
dutzhp 2003-08-14
  • 打赏
  • 举报
回复
up
阿青哥 2003-08-14
  • 打赏
  • 举报
回复
_bstr_t 类型变量赋值给LPCTSTR 的变量:内容被截短了。
我要飞得更高 2003-08-14
  • 打赏
  • 举报
回复
strConnect要不要转换啊
rafter263 2003-08-14
  • 打赏
  • 举报
回复
请会的大虾,留个言!懒得回答的大虾帮我顶一下吧! 谢谢啦:)

4,012

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧