【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“Demo12.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[])
{
//初始化Com对象
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);
_RecordsetPtr pRs("ADODB.Recordset");
pRs->Open("Select * From UserInfo", _variant_t(pConn, true),
adOpenStatic, adLockOpti
mistic, adCmdText);
if(pRs->Supports(adAddNew))
cout<<"支持adAddNew"<<endl;
if(pRs->Supports(adApproxPosition))
cout<<"支持adApproxPosition"<<endl;
if(pRs->Supports(adBookmark))
cout<<"支持adBookmark"<<endl;
if(pRs->Supports(adDelete))
cout<<"支持adDelete"<<endl;
if(pRs->Supports(adHoldRecords))
cout<<"支持adHoldRecords"<<endl;
if(pRs->Supports(adMovePrevious))
cout<<"支持adMovePrevious"<<endl;
if(pRs->Supports(adResync))
cout<<"支持adResync"<<endl;
if(pRs->Supports(adUpdate))
cout<<"支持adUpdate"<<endl;
if(pRs->Supports(adUpdateBatch))
cout<<"支持adUpdateBatch"<<endl;
if(pRs->Supports(adIndex))
cout<<"支持adIndex"<<endl;
if(pRs->Supports(adSeek))
cout<<"支持adSeek"<<endl;
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;
}
}
return 0;
}