Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an instance of the SqlDataSourceEnumerator, which can be used to retrieve information about available SQL Server instances.
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
An instance of the SqlDataSourceEnumerator used to retrieve information about available SQL Server instances.
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 = _
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();
}
}
The SqlDataSourceEnumerator class does not provide a constructor. Use the Instance property to retrieve an instance of the class instead.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in