سؤال

My application needs to ask the user what SQL Server to connect to and what credentials to use for the connection, and I was wondering if there's a dialog box out there that somebody has already built - functioning like the OpenFileDialog that comes with the framework (in that you .Show it, then you can ask it which file was picked), but looking like the login box from SQL Management Studio.

Ideally, I'd .Show the dialog, and then once it finished, I could get a .ConnectionString property that returned the string associated with all the details they picked.

If once doesn't exist, I'd like to start the process to create it, because I imagine it would be helpful for people to just be able to drop on a form and have getting a database connection from the user taken care of.

هل كانت مفيدة؟

المحلول

Yes, the 'Connection Properties' dialog box that is used within Visual Studio is also available as a stand-alone component:

http://code.msdn.microsoft.com/Connection

alt text

نصائح أخرى

Not that I'm aware of, however it should be fairly simple to whip one up and you can use the SQL Server SMO objects which should have all the methods you need.

http://msdn.microsoft.com/en-us/library/ms162169.aspx

I don't have one, because typically the application in production logs in to the same sql server, so they only enter their userID and pwd.

Should they be able to access any sql server, or are there business terms you could use to hide the actual server name?

Say your application needs to know if they want to log on to the dev, test, or prod server. You could have a drop-down with those 3 values and a lookup somewhere to the server names. Then you just need the standard userID and pwd entries.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top