⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo11.cpp

📁 《AE库通用模块及典型系统开发实例导航》光盘内容分享!
💻 CPP
字号:
// ADODemo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"

//导入ADO类型库
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")


int main(int argc, char* argv[])
{
	CoInitialize(NULL);

	_ConnectionPtr pConn("ADODB.Connection");

	try
	{		
		pConn->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Demo.mdb;Persist Security Info=False";
		
		pConn->Open("", "", "", adConnectUnspecified);

		_CommandPtr pCmd("ADODB.Command");

		pCmd->ActiveConnection = pConn;

		pCmd->CommandText = "Select * From UserInfo Where UserName = \"wzy\"";

		_RecordsetPtr pRs = pCmd->Execute(NULL, NULL, adCmdText);

		
		while(!pRs->EndOfFile)
		{
			cout<<"UserName:"<<_bstr_t(pRs->GetCollect("UserName"))<<"\t";
			cout<<"Password:"<<_bstr_t(pRs->GetCollect("Password"))<<endl;
			pRs->MoveNext();
		}

		pConn->Close();

	}
	catch(_com_error &e)
	{
		cout<<e.ErrorMessage()<<endl;

		for(long i = 0; i < pConn->Errors->Count; i++)
		{
			cout<<pConn->Errors->GetItem(_variant_t(i))->Description<<endl;
		}
	}


	CoUninitialize();

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -