Using the new data connection properties controls in VS 2005
Have you ever wanted to display the data connections dialog to your end user ? Well in VS 2005 there’s a set of new controls you can use to do it…
First add references to the following two assemblies:
- Microsoft.Data.ConnectionUI
- Microsoft.Data.ConnectionUI.Dialog
You’ll find these two assemblies in your Visual Studio IDE folder. You’ll need to distribute them with your app, 6KB and 384KB respectively, if the user doesn’t have Visual Studio installed, but As David pointed out these assemblies are not listed in the redist.txt, so you probably are NOT allowed to redistribute them. That is, you can only use these if the user has Visual Studio installed, which of course is totally ridiculous as these files come with FREE versions of Visual Studio !!!
Once you have got these assemblies then you can easily add a connection control to a from and have your own connection dialog. For example to add the dialogue as you’d see it for a SQLconnection, you can just add a new
Microsoft.Data.ConnectionUI.SqlConnectionUIControl
control to your form.
The only other thing you need to do is initialize the SqlConnectionUIControl. You do this by supplying the control with an IDataconnectionProperties implementation, in this case an
Microsoft.Data.ConnectionUI.SqlConnectionProperties
is the perfect fit 🙂
So assuming you named your SqlConnectionUIControl as SqlConnectionUI and declared it WithEvents, your code to intialise it might look something like this:
Private props As New Microsoft.Data.ConnectionUI.SqlConnectionProperties
Private Sub SQlConnectionUI_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles SQlConnectionUI.Load
SQlConnectionUI.Initialize(props)
EndSub
And there you have a simple SQL connection dialog.
Are you sure these are legally allowed to be redistributable?
redist.txt within the Visual Studio folder doesn’t mention them.