采用ADO连接数据库.doc





《采用ADO连接数据库.doc》由会员分享,可在线阅读,更多相关《采用ADO连接数据库.doc(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、连接数据库首先编辑UDL文件。新建一个txt文件,将其后缀名改为udl即可配置;在头文件中加入:#pragma warning(disable:4146)#import C:Program FilesCommon FilesSystemADOmsado15.dll named_guids rename(EOF,adoEOF), rename(BOF,adoBOF)#pragma warning(default:4146)using namespace ADODB;#include icrsint.h#include comutil.h/对COM组件进行初始化#include comdef.h在
2、cpp文件中:_ConnectionPtrm_pConnection;_RecordsetPtr m_pRecordset;if FAILED(:CoInitialize(NULL)CATDlgNotify * pPromptBox = new CATDlgNotify(CATApplicationFrame:GetApplicationFrame()-GetMainWindow(), 提示, CATDlgNfyInformation); pPromptBox-SetText(初始化COM库失败!); pPromptBox-SetVisibility(CATDlgShow);return ;H
3、RESULT hr;if(FAILED(m_pConnection.CreateInstance(ADODB.Connection) /ADODB.Connection或_uuidof(Connection) coutError, Unicom: Create the Instance Failed!GetMainWindow(), 提示, CATDlgNfyInformation); pPromptBox-SetText(创建_ConnectionPtr对象失败!); pPromptBox-SetVisibility(CATDlgShow);m_pConnection-Release();
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 采用 ADO 连接 数据库

限制150内