By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,695 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

Sql Server connection dialog control?

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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/de...csmpsqldmo.asp

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

http://msdn.microsoft.com/library/de...wseconnect.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

Nov 17 '05 #2

P: n/a
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/de...csmpsqldmo.asp

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

http://msdn.microsoft.com/library/de...wseconnect.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

Nov 17 '05 #3

P: n/a
Answering my own question:

SQL-DMO has the methods needed to get the server and database list. I made
my own user control to do what I wanted

Here's a good article that demonstrates this for c#:

http://www.csharphelp.com/archives2/archive342.html

Bill Faulk

"Wysiwyg" <wy*****@xmissionNSPAM.com> wrote in message
news:Ol**************@TK2MSFTNGP15.phx.gbl...
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.
.... 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

Nov 17 '05 #4

P: n/a
Answering my own question:

SQL-DMO has the methods needed to get the server and database list. I made
my own user control to do what I wanted

Here's a good article that demonstrates this for c#:

http://www.csharphelp.com/archives2/archive342.html

Bill Faulk

"Wysiwyg" <wy*****@xmissionNSPAM.com> wrote in message
news:Ol**************@TK2MSFTNGP15.phx.gbl...
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.
.... 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

Nov 17 '05 #5

P: n/a
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.
<bi********@netscape.net> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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/de...csmpsqldmo.asp
There is also something called SQLBrowseConnect which I know little
about, but here's a link:

http://msdn.microsoft.com/library/de...wseconnect.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

Nov 17 '05 #6

P: n/a
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.
<bi********@netscape.net> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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/de...csmpsqldmo.asp
There is also something called SQLBrowseConnect which I know little
about, but here's a link:

http://msdn.microsoft.com/library/de...wseconnect.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

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.