运行期显示数据链接属性窗口,取得ADO连接字串

类别:编程语言 点击:0 评论:0 推荐:

#include <atl/atlbase.h>

#include <msdasc.h>

#include <adodb.hpp>

 

WideString BuildConnectionStr()

{

  WideString ConnectionStr;

  CComPtr<IDataSourceLocator> pDsl;

  CComQIPtr<_Connection> pConn;

 

  CoInitialize(NULL);

  try

  {

    if(S_OK ==pDsl.CoCreateInstance(__uuidof(DataLinks)))

    {

      if(S_OK == pDsl->PromptNew((IDispatch**)&pConn))

      {

        pConn->Get_ConnectionString(ConnectionStr);

        return ConnectionStr;

      }

    }

  }

  __finally

  {

    CoUninitialize();

  }

}

本文地址:http://com.8s8s.com/it/it27878.htm