Click here to Skip to main content
15,915,324 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I'm trying to download sample code of how to detect SQL Server Instances on a Network, but all I'm getting are adds but no file download.

What is happening?
Posted
Comments
[no name] 8-Jul-12 11:22am    
Really? How is it that you expect us to know what it is that you are doing?

1 solution

It's hardly a major download:

C#
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
DataTable dt = instance.GetDataSources();
foreach (System.Data.DataRow row in dt.Rows)
    {
    Console.WriteLine("ServerName = {0}", row["ServerName"]);
    }
or
C#
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
DataTable dt = instance.GetDataSources();
foreach (System.Data.DataRow row in dt.Rows)
    {
    foreach (System.Data.DataColumn col in dt.Columns)
        {
        Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
        }
    Console.WriteLine("============================");
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900