Question

I would like to offer a database connection prompt to the user. I can build my own, but it would be nice if I can use something that somebody else has already built (maybe something built into Windows or a free library available on the Internet). Anybody know how to do this in .Net?

EDIT: I found this and thought it was interesting: Showing a Connection String prompt in a WinForm application. This only works for SQL Server connections though.

Was it helpful?

Solution

You might want to try using SQL Server Management Objects. This MSDN article has a good sample for prompting and connecting to a SQL server.

OTHER TIPS

ADO.NET has the handy ConnectionStringBuilder which will construct and validate a connection string. This would at least take the grunt work out of one part, allowing you to create a simple dialog box for the input.

Microsoft has released the source code for the data connection dialog on Code Gallery.

Here is an blog post from Yaohai with more info and here is the home of Data Connection Dialog on Code Gallery.

I combined the PropertyGrid Class with the SqlConnectionStringBuilder Class in a separate dialog and that worked really well for me.

The only "built in" connection string functionality that I could think of is the one that comes up when you run a CMD script (essentially a batch file) that runs SQL scripts. However I'm not sure if it's something built into Visual Studio.

It's really simple to make one anyway. If you don't want the user to be able to input a straight-out connection string, you can put together one made up of four textboxes and a checkbox:

  • Server
  • Catalog Name
  • checkbox for integrated security or SQL Authentication
  • Username
  • Password

Fairly trivial, IMHO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top