winforms connection properties dialog for configuration string

混江龙づ霸主 提交于 2019-12-02 20:53:11
FerranB

Look for this article explaining exactly what are you looking for. What she say is the following:

  1. You will need to add a couple references to your project:

    • OLE DB Service Component 1.0 Type Library
    • Microsoft ActiveX Data Objects 2.x Library
  2. Use the following code:

    using MSDASC;
    using ADODB;
    
    private string BuildConnectionString()
    {
         string strConnString = "";
         object _con = null;
         MSDASC.DataLinks _link = new MSDASC.DataLinks();
         _con = _link.PromptNew();
         if (_con == null) return string.Empty;
         strConnString = ((ADODB.Connection)_con).ConnectionString;
         return strConnString;
    }
    
Thomas Levesque

I was looking for exactly that, and it appears that Microsoft has published the source for the Visual Studio connection dialog, so that it can be used outside VS :

I just tried it, it works fine :)

Update 7/2019

Since the Microsoft Code site is dark, and there doesn't seem to be an official Microsoft posting for Data Connection Dialog, here is a link to a Github user repository with the Microsoft code.

https://github.com/kjbartel/ConnectionDialog

Original but now dead link http://code.msdn.microsoft.com/Connection

It's quite old, but there's this article - might have some inspiration for you.

I don't know if there exists a 'predefined' form for it, but, you could offcourse create your own form, and use one the DbConnectionStringBuilder classes (SqlConnectionStringBuilder, OracleConnectionStringBuilder, OleDbConnectionStringBuilder) to create the connectionstring from the parameters the user entered on your custom created form.

You can also use Universal Data Link Files

http://msdn.microsoft.com/en-us/library/e38h511e%28VS.71%29.aspx

Work with XP but I never tried it in Vista or Seven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!