【VC开源代码栏目提醒】:本文主要为网学会员提供Demo3.cpp,希望对需要Demo3.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);
try
{
//初始化数据库连接对象
_ConnectionPtr pConn("ADODB.Connection");
//打开数据库连接
pConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Demo.mdb;Persist Security Info=False", "", "", adConnectUnspecified);
cout<<pConn->Provider<<endl;
//关闭数据库连接
pConn->Close();
}
catch(_com_error &e)
{
cout<<e.ErrorMessage()<<endl;
}
return 0;
}
上一篇:
Demo2.cpp
下一篇:
企业管理论文:电力企业管理中的绩效考核工作