Sdílet prostřednictvím


SqlDataSourceEnumerator.Instance Vlastnost

Definice

Získá instanci objektu SqlDataSourceEnumerator, který lze použít k načtení informací o dostupných instancích SQL Serveru.

public:
 static property System::Data::Sql::SqlDataSourceEnumerator ^ Instance { System::Data::Sql::SqlDataSourceEnumerator ^ get(); };
public static System.Data.Sql.SqlDataSourceEnumerator Instance { get; }
static member Instance : System.Data.Sql.SqlDataSourceEnumerator
Public Shared ReadOnly Property Instance As SqlDataSourceEnumerator

Hodnota vlastnosti

Instance SqlDataSourceEnumerator použité k načtení informací o dostupných instancích SQL Serveru.

Příklady

Následující konzolová aplikace zobrazí seznam všech dostupných instancí SYSTÉMU SQL Server 2005 v místní síti. Tento kód používá metodu Select k filtrování řádků v tabulce vrácené metodou GetDataSources .

Imports System.Data.Sql

Module Module1
  Sub Main()
    ' Retrieve the enumerator instance, and
    ' then retrieve the data sources.
    Dim instance As SqlDataSourceEnumerator = _
     SqlDataSourceEnumerator.Instance
    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(row("ServerName"))
    Next
    Console.WriteLine("Press any key to continue.")
    Console.ReadKey()
  End Sub
End Module
using System.Data.Sql;

class Program
{
  static void Main()
  {
    // Retrieve the enumerator instance, and
    // then retrieve the data sources.
    SqlDataSourceEnumerator instance =
      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(row["ServerName"]);
    }
    Console.WriteLine("Press any key to continue.");
    Console.ReadKey();
  }
}

Poznámky

Třída SqlDataSourceEnumerator neposkytuje konstruktor. Instance Místo toho použijte vlastnost k načtení instance třídy.

Platí pro

Viz také