MFC通过ADO连接Oracle数据库

程序的代码如下:
1、在”StdAfx.h”文件中导入库:

#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF")

2、在类里添加成员变量:

_ConnectionPtr m_pCnn;

3、连接数据库:

m_pCnn.CreateInstance(__uuidof(Connection));
try{
m_pCnn->ConnectionTimeout = 5;                          //设置连接时间
m_pCnn->Open(_bstr_t(sConn),strUserID,strPwd,adModeUnknown);
return true;
}
catch(_com_error e){
AfxMessageBox(e.Description());
return false;
}

在调试时如果出现以下错误: 继续阅读“MFC通过ADO连接Oracle数据库”