DataConnection Dialog

by 27. July 2007 12:28

Here's how to display the DataConnection dialog at runtime allowing the user to define which datasource to connect.

ie. to display these :

ChooseDataSource

ConnectionProperties

 

In your project Add references to :

Microsoft.Data.ConnectionUI.dll
Microsoft.Data.ConnectionUI.Dialog.dll

You can find these under : <Visual Studio>\Common7\IDE folder.

Then in your code :

DataConnectionDialog dlg = new DataConnectionDialog();
DataSource.AddStandardDataSources(dlg);
switch (DataConnectionDialog.Show(dlg))
{
    case DialogResult.OK:
        textConnectionString.Text = dlg.ConnectionString;
        break;
}