I add Microsoft.Data.ConnectionUI.Dialog.dll and Microsoft.Data.ConnectionUI.dll dlls to my project, and use this code:
Microsoft.Data.ConnectionUI.DataConnectionDialog dcd = new Microsoft.Data.ConnectionUI.DataConnectionDialog();
Microsoft.Data.ConnectionUI.DataSource.AddStandardDataSources(dcd);
if (Microsoft.Data.ConnectionUI.DataConnectionDialog.Show(dcd) == System.Windows.Forms.DialogResult.OK)
{
//
}
else
{
//
}
When I use this in normal windows applications, everything seems to be ok (shows standard VS dataconnection dialog with Advanced button). When I use it in SETUP PROJECT, it shows only the advanced dialog AND the OK button is disabled. Users can test the connection but can not press OK button.
Does anyone know what why this is not working?
The buttons are enabled/disabled depending on the settings.
In this article: http://erikej.blogspot.com.au/2010/04/using-adonet-data-connection-dialog-in.html the author “hardcodes” the datasource and this consequentially disables the “Change” button.
When you set the DataSource name, the OK button should be enabled. I dug up the
Data Connection Dialog Source Codecode to show you:http://archive.msdn.microsoft.com/Connection/Release/ProjectReleases.aspx?ReleaseId=3863
In the Micrsost.Data.ConnectionUI.Dialog project, open the DataConnectionDialog.cs class and you can see this is the event:
The above event is hooked up from the ConnectionProperties method and is invoked each time the PropertyChange event fires:
To get the OK button enabled you will need to satisfy the ConnectionProperties.IsComplete condition.