ADO访问Oracle数据库,连接异常(Unknown error 0x800a0e7a)
代码如下:执行Open过程中出现异常,信息为Unknown error 0x800a0e7a
C++ Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
|
try
{ strConnect = L
"Provider=ORAOLEDB.ORACLE.1;Password="
+ user_password + L
";User ID="
+ user_name + L
";Data Source="
+ server_ip + L
"/"
+ oracle_dbname + L
";Unicode=True;Persist Security Info=True"
; m_pConn->ConnectionTimeout = connect_timeout; HRESULT Ret = m_pConn->Open((_bstr_t)strConnect.c_str(), user_name.c_str(), user_password.c_str(), adModeUnknown);
if
(Ret != S_OK) { DEBUG_TRACE_ERROR(WSTR(
"CKmObjectDataSourceORCL_KmServerConnect_1,EER:ORACLE(%s)连接失败.,%s:%d"
), connectstr_temp.c_str(), __WFUNCTION__, __LINE__);
return
-
1
; } }
catch
(_com_error e) { std::wstring result_unicode = (
wchar_t
*)e.ErrorMessage(); DEBUG_TRACE_ERROR(WSTR(
"CKmObjectDataSourceORCL_KmServerConnect_0,EER:ORACLE(%s)连接异常(%s).,%s:%d"
), connectstr_temp.c_str(), result_unicode.c_str(), __WFUNCTION__, __LINE__);
return
-
1
; }
|
解决方法:
OLEDB连接Oracle分为两种方式,即分别微软和Oracle写的不同的驱动。 provider=MSDAORA.1是微软写的驱动 provider=OraOLEDB.Oracle是Oracle自带的驱动(可能缺失!)
安装ODTwithODAC(下载),即Oracle Data Access Components,用于访问Oracle的组件。
参考:http://www.cnblogs.com/SharkBin/archive/2013/08/29/3289554.html |