Aracılığıyla paylaş


SqlDataSourceEnumerator.Instance Özellik

Tanım

Kullanılabilir SQL Server örnekleri hakkında bilgi almak için kullanılabilecek bir örneğini SqlDataSourceEnumeratoralır.

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

Özellik Değeri

Kullanılabilir SQL Server örnekleri hakkında bilgi almak için kullanılan örneği SqlDataSourceEnumerator .

Örnekler

Aşağıdaki konsol uygulaması, yerel ağ içindeki tüm kullanılabilir SQL Server 2005 örneklerinin listesini görüntüler. Bu kod, Select yöntemi tarafından döndürülen tablodaki satırları filtrelemek GetDataSources için yöntemini kullanır.

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();
  }
}

Açıklamalar

SqlDataSourceEnumerator sınıfı bir oluşturucu sağlamaz. Instance Bunun yerine sınıfının bir örneğini almak için özelliğini kullanın.

Şunlara uygulanır

Ayrıca bkz.