|
1 | | -<?xml version="1.0"?> |
2 | | -<docs> |
3 | | - <members name="SqlDataSourceEnumerator"> |
| 1 | +<docs> |
| 2 | + <members name="SqlDataSourceEnumerator"> |
4 | 3 | <SqlDataSourceEnumerator> |
5 | | - <summary>Provides a mechanism for enumerating all available instances of SQL Server within the local network.</summary> |
6 | | - <remarks> |
7 | | - <format type="text/markdown"><![CDATA[ |
8 | | - |
9 | | -## Remarks |
10 | | -SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class exposes this information to the application developer, providing a <xref:System.Data.DataTable> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the `Connection Properties` dialog box, expands the drop-down list containing all the available servers. |
11 | | -
|
12 | | - ]]></format> |
13 | | - </remarks> |
14 | | - <related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> |
15 | | - </SqlDataSourceEnumerator> |
16 | | - <GetDataSources> |
17 | | - <summary>Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances.</summary> |
18 | | - <returns>A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances.</returns> |
19 | | - <remarks> |
20 | | - <format type="text/markdown"><![CDATA[ |
21 | | - |
22 | | -## Remarks |
23 | | -The table returned by this method contains the following columns, all of which contain strings: |
24 | | -
|
25 | | -|Column|Description| |
26 | | -|------------|-----------------| |
27 | | -|**ServerName**|Name of the server.| |
28 | | -|**InstanceName**|Name of the server instance. Blank if the server is running as the default instance.| |
29 | | -|**IsClustered**|Indicates whether the server is part of a cluster.| |
30 | | -|**Version**|Version of the server:<br /><br />10.0.xx for SQL Server 2008<br />10.50.x for SQL Server 2008 R2<br />11.0.xx for SQL Server 2012<br />12.0.xx for SQL Server 2014<br />13.0.xx for SQL Server 2016<br />14.0.xx for SQL Server 2017| |
31 | | - |
32 | | -> [!NOTE] |
33 | | -> Due to the nature of the mechanism used by <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical. |
34 | | -
|
35 | | -## Examples |
36 | | - The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window. |
37 | | - |
38 | | -[!code-csharp[SqlDataSourceEnumerator.Example#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)] |
39 | | - |
40 | | - ]]></format> |
41 | | - </remarks> |
42 | | - <related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> |
43 | | - </GetDataSources> |
| 4 | + <summary> |
| 5 | + Provides a mechanism for enumerating all available instances of SQL Server within the local network. |
| 6 | + </summary> |
| 7 | + <remarks> |
| 8 | + SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> class exposes this information to the application developer, providing a <see cref="T:System.Data.DataTable" /> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the <c>Connection Properties</c> dialog box, expands the drop-down list containing all the available servers. |
| 9 | + </remarks> |
| 10 | + <seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server"> |
| 11 | + Enumerating Instances of SQL Server |
| 12 | + </seealso> |
| 13 | + </SqlDataSourceEnumerator> |
| 14 | + <GetDataSources> |
| 15 | + <summary> |
| 16 | + Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances. |
| 17 | + </summary> |
| 18 | + <returns> |
| 19 | + A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances. |
| 20 | + </returns> |
| 21 | + <remarks> |
| 22 | + <para> |
| 23 | + The table returned by this method contains the following columns, all of which contain strings: |
| 24 | + </para> |
| 25 | + <para> |
| 26 | + <list type="table"> |
| 27 | + <listheader> |
| 28 | + <term>Column</term> |
| 29 | + <description>Description</description> |
| 30 | + </listheader> |
| 31 | + <item> |
| 32 | + <term><b>ServerName</b></term> |
| 33 | + <description>Name of the server.</description> |
| 34 | + </item> |
| 35 | + <item> |
| 36 | + <term><b>InstanceName</b></term> |
| 37 | + <description>Name of the server instance. Blank if the server is running as the default instance.</description> |
| 38 | + </item> |
| 39 | + <item> |
| 40 | + <term><b>IsClustered</b></term> |
| 41 | + <description>Indicates whether the server is part of a cluster.</description> |
| 42 | + </item> |
| 43 | + <item> |
| 44 | + <term><b>Version</b></term> |
| 45 | + <description> |
| 46 | + Version of the server: |
| 47 | + <list type="bullet"> |
| 48 | + <item>10.0.xx for SQL Server 2008</item> |
| 49 | + <item>10.50.x for SQL Server 2008 R2</item> |
| 50 | + <item>11.0.xx for SQL Server 2012 </item> |
| 51 | + <item>12.0.xx for SQL Server 2014</item> |
| 52 | + <item>13.0.xx for SQL Server 2016</item> |
| 53 | + <item>14.0.xx for SQL Server 2017</item> |
| 54 | + </list> |
| 55 | + </description> |
| 56 | + </item> |
| 57 | + </list> |
| 58 | + <note type="note"> |
| 59 | + Due to the nature of the mechanism used by <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical. |
| 60 | + </note> |
| 61 | + </para> |
| 62 | + </remarks> |
| 63 | + <example> |
| 64 | + <para> |
| 65 | + The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window. |
| 66 | + </para> |
| 67 | + <!-- SqlDataSourceEnumeratorExample --> |
| 68 | + <code language="c#"> |
| 69 | + using System; |
| 70 | + using Microsoft.Data.Sql; |
| 71 | + |
| 72 | + class Program |
| 73 | + { |
| 74 | + static void Main() |
| 75 | + { |
| 76 | + // Retrieve the enumerator instance and then the data. |
| 77 | + SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; |
| 78 | + System.Data.DataTable table = instance.GetDataSources(); |
| 79 | + |
| 80 | + // Display the contents of the table. |
| 81 | + DisplayData(table); |
| 82 | + |
| 83 | + Console.WriteLine("Press any key to continue."); |
| 84 | + Console.ReadKey(); |
| 85 | + } |
| 86 | + |
| 87 | + private static void DisplayData(System.Data.DataTable table) |
| 88 | + { |
| 89 | + foreach (System.Data.DataRow row in table.Rows) |
| 90 | + { |
| 91 | + foreach (System.Data.DataColumn col in table.Columns) |
| 92 | + { |
| 93 | + Console.WriteLine("{0} = {1}", col.ColumnName, row[col]); |
| 94 | + } |
| 95 | + Console.WriteLine("============================"); |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + </code> |
| 100 | + </example> |
| 101 | + <seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server"> |
| 102 | + Enumerating Instances of SQL Server |
| 103 | + </seealso> |
| 104 | + </GetDataSources> |
44 | 105 | <Instance> |
45 | | - <summary>Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/>, which can be used to retrieve information about available SQL Server instances.</summary> |
46 | | - <value>An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/> used to retrieve information about available SQL Server instances.</value> |
47 | | - <remarks> |
48 | | - <format type="text/markdown"><] |
54 | | -
|
55 | | -## Examples |
56 | | -The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <xref:System.Data.DataTable.Select%2A> method to filter the rows in the table returned by the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources%2A> method. |
57 | | - [!code-csharp[SqlDataSourceEnumeratorVersionExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorVersionExample.cs#1)] |
58 | | -
|
59 | | - ]]></format> |
60 | | - </remarks> |
61 | | - <related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related> |
62 | | - |
| 106 | + <summary> |
| 107 | + Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> , which can be used to retrieve information about available SQL Server instances. |
| 108 | + </summary> |
| 109 | + <value> |
| 110 | + An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> used to retrieve information about available SQL Server instances. |
| 111 | + </value> |
| 112 | + <remarks> |
| 113 | + <para> |
| 114 | + The <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> class does not provide a constructor. Use the <see cref="P:Microsoft.Data.Sql.SqlDataSourceEnumerator.Instance" /> property to retrieve an instance of the class instead. |
| 115 | + </para> |
| 116 | + <!-- SqlDataSourceEnumeratorExample --> |
| 117 | + <code language="c#"> |
| 118 | + using System; |
| 119 | + using Microsoft.Data.Sql; |
| 120 | + |
| 121 | + class Program |
| 122 | + { |
| 123 | + static void Main() |
| 124 | + { |
| 125 | + // Retrieve the enumerator instance and then the data. |
| 126 | + SqlDataSourceEnumerator instance = |
| 127 | + SqlDataSourceEnumerator.Instance; |
| 128 | + System.Data.DataTable table = instance.GetDataSources(); |
| 129 | + |
| 130 | + // Display the contents of the table. |
| 131 | + DisplayData(table); |
| 132 | + |
| 133 | + Console.WriteLine("Press any key to continue."); |
| 134 | + Console.ReadKey(); |
| 135 | + } |
| 136 | + |
| 137 | + private static void DisplayData(System.Data.DataTable table) |
| 138 | + { |
| 139 | + foreach (System.Data.DataRow row in table.Rows) |
| 140 | + { |
| 141 | + foreach (System.Data.DataColumn col in table.Columns) |
| 142 | + { |
| 143 | + Console.WriteLine("{0} = {1}", col.ColumnName, row[col]); |
| 144 | + } |
| 145 | + Console.WriteLine("============================"); |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + </code> |
| 150 | + </remarks> |
| 151 | + <example> |
| 152 | + <para> |
| 153 | + The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <see cref="M:System.Data.DataTable.Select" /> method to filter the rows in the table returned by the <see cref="M:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources" /> method. |
| 154 | + </para> |
| 155 | + <!-- SqlDataSourceEnumeratorVersionExample --> |
| 156 | + <code language="c#"> |
| 157 | + using System; |
| 158 | + using Microsoft.Data.Sql; |
| 159 | + |
| 160 | + class Program |
| 161 | + { |
| 162 | + static void Main() |
| 163 | + { |
| 164 | + // Retrieve the enumerator instance, and |
| 165 | + // then retrieve the data sources. |
| 166 | + SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; |
| 167 | + System.Data.DataTable table = instance.GetDataSources(); |
| 168 | + |
| 169 | + // Filter the sources to just show SQL Server 2012 instances. |
| 170 | + System.Data.DataRow[] rows = table.Select("Version LIKE '11%'"); |
| 171 | + foreach (System.Data.DataRow row in rows) |
| 172 | + { |
| 173 | + Console.WriteLine(row["ServerName"]); |
| 174 | + } |
| 175 | + |
| 176 | + Console.WriteLine("Press any key to continue."); |
| 177 | + Console.ReadKey(); |
| 178 | + } |
| 179 | + } |
| 180 | + </code> |
| 181 | + </example> |
| 182 | + <seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server"> |
| 183 | + Enumerating Instances of SQL Server |
| 184 | + </seealso> |
63 | 185 | </Instance> |
64 | | - </members> |
| 186 | + </members> |
65 | 187 | </docs> |
0 commit comments