- Posted by ehosca on July 27, 2007
Here's how to display the DataConnection dialog at runtime allowing the user to define which datasource to connect.
ie. to display these :
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;
}