Sql Server connection dialog control?

W

Wysiwyg

I'm writing an application in C# with Visual Studio 2003.

I want to put a sql server connection dialog on a form used to configure an
application. This is for setting up the connection and saving the
user,password, server, and database with a "test connection" button. This is
for a configuration form as opposed to having the connection dialog
automatically pop-up every time the user starts the application and tries to
connect to a datasource.

Obviously, I can just have the user enter the user id, password, server, and
database but I'm looking to include the drop down lists of available servers
and databases like what is usually seen when creating database connections
without having to write the whole thing myself. I want a control to do this
ahead of actually running the application; it's just for saving the
connection settings. I am NOT looking to have the standard dialog show up
when the actual connection to the database is needed. I want to embed the
input fields into a form and not have a dialog pop up.

Is there already a library with this functionality? Something with a
"GetServerList" and "GetDatabaseList" type of methods if not an entire
control with all of the input fields?

Thanks!
Bill Faulk
 
B

billmiami2

I'm not sure if there is a set of .NET classes, but if you're willing
to use com interop, you can use the SQLDMO library. A method exists
called

ListAvailableSQLServers

Which will allow you to list the SQL Servers on the network. SQLDMO
also provides you with the ability to get to the details of any SQL
object so creating lists of databases, tables, columns and their
attributes is very simple. You can get samples at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpsqldmo.asp

There is also something called SQLBrowseConnect which I know little
about, but here's a link:

http://msdn.microsoft.com/library/d.../htm/odbcconnecting_with_sqlbrowseconnect.asp

If you don't want to use SQLDMO, you can create a couple of simple
stored procedures. To list available SQL Servers, you can create a
stored procedure based on the extended procedure

exec master..xp_cmdshell 'ISQL -L'

Which will give you a list that likely needs a bit of formatting. From
there, you can create a listing of the databases on the server by
writing a procedure based on the sysdatabases table or executing
sp_helpdb. I like this approach because it's nice and simple.

Bill E.
Hollywood, FL
 
W

Wysiwyg

Thanks Bill,

SQL DMO is just what I was looking for. The DMO Methods for listing servers
and enumerating the databases were what I needed to write my user control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,088
Members
48,773
Latest member
Kaybee

Latest Threads

Top