Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

winforms connection properties dialog for configuration string

Is there a way to display the connection properties dialog for connection string browsing(for database) in run time?

As I want the user to be able to connect to various database using the GUI. The same one as we get in visual studio connection properties dialog.

Thanks in Advance

http://www.freeimagehosting.net/uploads/c59e853019.jpg

like image 831
Thunder Avatar asked Feb 05 '10 08:02

Thunder


People also ask

How do I change my connection string?

To edit a connection string stored in application settingsLocate the connection you want to edit and select the text in the Value field. Edit the connection string in the Value field, or click the ellipsis (...) button in the Value field to edit your connection with the Connection Properties dialog box.

Where do I put connection string in web config?

After opening the web. config file in application, add sample db connection in connectionStrings section like this: <connectionStrings>

Where should you store the connection string information?

Connection strings in configuration files are typically stored inside the <connectionStrings> element in the app. config for a Windows application, or the web. config file for an ASP.NET application.


1 Answers

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;
    }
    
like image 103
FerranB Avatar answered Sep 19 '22 03:09

FerranB