小弟初学者,电脑上装了Oracle 10g,这里想问的是如何用c++语言连接数据库
我的语句是:
_ConnectionPtr m_pConnection;
::CoInitialize(NULL);
m_pConnection.CreateInstance(_uuidof(Connection));
m_pConnection->PutConnectionTimeout(10);
sprintf(szDBString,"Provider=OraOLEDB.Oracle.1;Password=%s;Persist Security Info=True;User ID=%s;Data Source= %s",m_strPswd,m_strUser,m_strIP);
try
{
m_pConnection->Open(szDBString, (class _bstr_t)m_strUser, (class _bstr_t)m_strPswd, adModeUnknown);
MessageBox("测试连接成功");
}
catch (_com_error e)
{
MessageBox("测试连接失败");
return ;
}
连接不上,请问我这问题在哪里啊??? 或者说对数据库上有什么特别设置吗? 我是安装后,也没做什么设置
我的语句是:
_ConnectionPtr m_pConnection;
::CoInitialize(NULL);
m_pConnection.CreateInstance(_uuidof(Connection));
m_pConnection->PutConnectionTimeout(10);
sprintf(szDBString,"Provider=OraOLEDB.Oracle.1;Password=%s;Persist Security Info=True;User ID=%s;Data Source= %s",m_strPswd,m_strUser,m_strIP);
try
{
m_pConnection->Open(szDBString, (class _bstr_t)m_strUser, (class _bstr_t)m_strPswd, adModeUnknown);
MessageBox("测试连接成功");
}
catch (_com_error e)
{
MessageBox("测试连接失败");
return ;
}
连接不上,请问我这问题在哪里啊??? 或者说对数据库上有什么特别设置吗? 我是安装后,也没做什么设置
解决方案 »
- 如何将CSocket的工作方式改为非阻塞?
- 希望高手能帮我解答~~一直困扰我的问题~~关于vfw的
- 关于include
- 急救!!recv阻塞问题
- ListBox的一个问题
- HELP
- 数据库服务器运行过程中弹出runtime error,请问这是怎么回事?
- 小问题,有关OnDraw
- 请问vc中怎样定义链表?(超级菜鸟)
- CExtraceView是CView的子类,那CExtraceView::ONCreate()不就等于CView::ONCreate()吗?那为何书上还要写成里边这样?请进。
- 求助!!!!求助!!!Dialogbox的用法。
- 如何PostThreadMessage到一个特定的线程上面? 线程是不命名的啊
Oracle是需要装客户端的。在客户端是需要配置服务名的
http://blog.csdn.net/Sat_shan/article/details/3536993
http://download.csdn.net/source/2882570
然后再GOOGLE一下TNS,你就知道为什么连接不上了