2

I've been writing some small maintenance/viewer tools that each connect to a SQLServer (2005) database via System.Data.SqlClient classes. (C# - .NET 3.5 - Windows.Forms)

For each of these tools I had to write the UI and dialog to let the user choose the right db and server: I connect to my test-db, my colleague uses my tools too and connects his test-db.

I'm looking for a plugable usercontrol that lets the user select a server, db and the rest of the connection parameters and that provides a SqlClient.SqlConnection to the rest of the application.

I've tried writing a usercontrol myself now, but I'm sure there must be others ,better ones and better tested ones. I've been Googling and looking at CodeProject, but found none.

1
  • I had a similar probme, stackoverflow.com/questions/736860/… If you fund good solution pleas public here, so and others can see how it can be done Commented Jul 9, 2009 at 13:09

2 Answers 2

3

There must be some better than one I wrote recently, because that one's so bad:

Just

  1. Create a user control
  2. drag a couple of buttons to it, anchor bottom center, make them ok and cancel
  3. drag a Property Grid control onto it, dock fill
  4. Add a read-only property to the control of type SqlConnectionStringBuilder, back it with a field
  5. Initialize the field to a new SqlConnectionStringBuilder instance
  6. In the Load event, set the Object property of the property grid to the SqlConnectionStringBuilder

That's pretty much that. The user just gets to fill in the properties. If you like, you can also create a ConnectionString property on the control and have it return the .ConnectionString property of the SqlConnectionStringBuilder.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for pointing me to the Property Grid Control. My solution wil do for now.
1

What you're describing here is simple enough that I doubt there's something out there that does only this. You'd probably be better off sticking with your own code here.

1 Comment

Agreed, this seems fairly straightforward to write.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.