tconstr.cpp

来自「如何调用系统数据库联接的对话框」· C++ 代码 · 共 41 行

CPP
41
字号
// tConStr.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "stdio.h"
#undef EOF
#import "c:\program files\common files\system\ole db\oledb32.dll" rename_namespace("dlinks")
#import "c:\program files\common files\system\ado\msado15.dll" rename_namespace("ado")

void TestConnection(void);



int _tmain(int argc, _TCHAR* argv[])
{

    TestConnection();

	return 0;
}

void TestConnection(void)
{
    using namespace dlinks;
	using namespace ado;
	
	HRESULT hr;
   	::CoInitialize( NULL );
   	IDataSourceLocatorPtr dlPrompt = NULL;
   	_ConnectionPtr conn = NULL;
   	hr = dlPrompt.CreateInstance(__uuidof(DataLinks));
   	conn = dlPrompt->PromptNew();
   	if ( NULL != conn )
   	{
   		printf( "Connect: %s\n", (char*) conn->ConnectionString );
   	}
   
	return;

}

⌨️ 快捷键说明

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