Instance Property
Collapse the table of content
Expand the table of content

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 Shared ReadOnly Property Instance As SqlDataSourceEnumerator

Property Value

Type: System.Data.Sql.SqlDataSourceEnumerator

An instance of the SqlDataSourceEnumerator used to retrieve information about available SQL Server instances.

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.

Imports System.Data.Sql

Module Module1
  Sub Main()
    ' Retrieve the enumerator instance, and
    ' then retrieve the data sources.
    Dim instance As SqlDataSourceEnumerator = _
    Dim table As System.Data.DataTable = instance.GetDataSources()

    ' Filter the sources to just show SQL Server 2005 instances.
    Dim rows() As DataRow = table.Select("Version LIKE '9%'")
    For Each row As DataRow In rows
    Console.WriteLine("Press any key to continue.")
  End Sub
End Module

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft