List available SQL Servers using VB.NET

I am looking for a reliable way to search for all available SQL Servers on a network.   I then need to be able to list the databases for a particular server.  I have done this in the past in VB6 applications using SQLDMO without problem.  I am wondering if their is a better or different way to do this using VB.NET and the .NET Framework version 3.5
Who is Participating?
Dim dtSQL As New DataTable
dtSQL = Sql.SqlDataSourceEnumerator.Instance.GetDataSources
DataGridView1.DataSource = dtSQL.AsDataView
This should query your network for all available instances of SQL server 2000 or 2005.
Mike_StevensAuthor Commented:
I tried the second methid you just posted.  It works but it is very, very slow
How big is your network, out of curiousity? The server enum takes about 10 seconds for me, but we only have around 200 workcenters.
Using the first method, you will just get the SQL server names available. Once you 'weed out' the non-server machines, you can then run the stored procedure 'sp_databases' against the servers to enumerate the db's.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.