#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "windows.h"
using namespace std;
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","EndOfFile")
int _tmain(int argc, _TCHAR* argv[])
{
	::CoInitialize(NULL);
	_RecordsetPtr recordP("ADODB.RecordSet");
	_ConnectionPtr connp("ADODB.Connection");
	try{
		connp.CreateInstance("ADODB.Connection");
		_bstr_t strSQL="Provider=SQLOLEDB;Server=WIN-4MOED8K4727,1433;DataBase=proTest;UID=cjr;PWD=123";
		connp->Open(strSQL,"","",adModeUnknown);
		cout<<"connection success"<<endl;
		if(connp==NULL){
			cout<<"error"<<endl;
		}
	}catch(_com_error e){
		cout<<e.Description()<<endl;
	}
	return 0;
}

C++ ADO连接  C++ ADO连接   C++ ADO连接 

相关文章:

  • 2022-12-23
  • 2022-01-23
  • 2021-07-09
  • 2022-12-23
  • 2021-10-08
  • 2021-11-25
  • 2021-09-12
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案