《VC++深入详解》中的使用ADO对象连接数据by VC++一例
来源:互联网 发布:开淘宝网店的费用 编辑:程序博客网 时间:2024/06/07 15:18
// consoleMfc.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "consoleMfc.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "rsEOF")/////////////////////////////////////////////////////////////////////////////// The one and only application objectCWinApp theApp;using namespace std;int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]){int nRetCode = 0;// initialize MFC and print and error on failureif (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)){// TODO: change error code to suit your needscerr << _T("Fatal Error: MFC initialization failed") << endl;nRetCode = 1;}else{// TODO: code your application's behavior here.CoInitialize(NULL);_ConnectionPtr pConn(__uuidof(Connection));_RecordsetPtr pRst(__uuidof(Recordset));_CommandPtr pCmd(__uuidof(Command));pConn->ConnectionString="Provider=MSDASQL.1;Password=123456;Persist Security Info=True;User ID=root;Data Source=xs_kc";pConn->Open("","","",adConnectUnspecified);pRst=pConn->Execute("select * from xs",NULL,adCmdText);while(!pRst->rsEOF){_bstr_t bst = (_bstr_t)pRst->GetCollect("姓名");// 其中的姓名可以使用打开的表中的字段名替换cout << (char*)(bst) << endl;pRst->MoveNext();}pRst->Close();pConn->Close();pCmd.Release();pRst.Release();pConn.Release();CoUninitialize();}return nRetCode;}
如果不加#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF", "rsEOF"), 编译时会提示_ConnectionPtr、_RecordsetPtr、_CommandPtr undeclared identifier
- 《VC++深入详解》中的使用ADO对象连接数据by VC++一例
- VC++中使用ADO连接数据库step by step
- VC++ ADO连接ACCESS详解
- vc 使用ADO连接 sqlserver
- VC使用ADO对象连接一个Access数据库
- Ado在vc++中的使用
- VC++通过ADO连接数据库(一)
- 配置数据源,VC++ ADO连接ACCESS详解
- VC++ ADO数据存取(一)
- VC使用UDL文件建立ADO连接
- VC下使用ADO连接数据库
- VC中使用ADO连接MSSQL
- VC++使用ADO连接SQL Server数据库
- VC++使用ADO连接SQL Server数据库
- VC++使用ADO连接SQL Server数据库
- VC使用ADO连接SQLServer数据库
- VC++中使用ADO连接数据库
- VC使用ADO连接SQLServer数据库
- Nancy HttpServer---自己开发HttpServer (不断更新中)
- python walk dir(遍历目录)
- oracle的多表insert操作
- [精华] 跟我一起写 Makefile
- 游戏开发基础(三)
- 《VC++深入详解》中的使用ADO对象连接数据by VC++一例
- Ajax的异步通信引发的一个随机性问题<2> 异步请求的问题来了
- 导出
- J2EE核心技术--EJB分类
- Android自动测试之Monkey工具
- 黑马程序员_GUI
- sina绑定手机
- Android自动测试之monkeyrunner工具
- 电容感应触摸屏工作原理