Url: http://wilderminds.blob.core.windows.net/downloads/TestDataConnect…
Chris Sells asked me today if there was a re-usable connection string user interface that I knew of. I’d heard that you could use the dialog from Visual Studio, but I had to dig in and remember how. I’ve put together this quick and dirty example for downloading.
The trick is two fold:
DataConnectionDialog dlg = new DataConnectionDialog();
DataSource.AddStandardDataSources(dlg);
if (DataConnectionDialog.Show(dlg) == DialogResult.OK)
{
textBox1.Text = dlg.ConnectionString;
textBox2.Text = dlg.SelectedDataProvider.DisplayName;
}
The sample includes how to find out if the user wants to save the provider and skip that part of the dialog everytime. Let me kow what you think!