SqlDataSourceEnumerator.Instance Property

Gets an instance of the SqlDataSourceEnumerator, which can be used to retrieve information about available SQL Server instances.

Namespace: System.Data.Sql
Assembly: System.Data (in system.data.dll)

public static SqlDataSourceEnumerator Instance { get; }
/** @property */
public static SqlDataSourceEnumerator get_Instance ()

public static function get Instance () : SqlDataSourceEnumerator

Not applicable.

Property Value

A SqlDataSourceEnumerator.

The SqlDataSourceEnumerator class does not provide a constructor. Use the Instance property to retrieve an instance of the class instead.

The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the Select method to filter the rows in the table returned by the GetDataSources method.

using System.Data.Sql;

class Program
  static void Main()
    // Retrieve the enumerator instance, and
    // then retrieve the data sources.
    SqlDataSourceEnumerator instance =
    System.Data.DataTable table = instance.GetDataSources();

    // Filter the sources to just show SQL Server 2005 instances.
    System.Data.DataRow[] rows = table.Select("Version LIKE '9%'");
    foreach (System.Data.DataRow row in rows)
    Console.WriteLine("Press any key to continue.");

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0