Some data providers now give you the ability to enumerate a list of data sources. For the SQL Server provider, this is a list of available SQL servers. Each data provider will return a DataTable containing different information about the available data sources.
The code in Listing 19.4 shows sample code to determine whether a data provider supports the ability to enumerate data sources and how to examine that list of data sources.
Listing 19.4. Enumerating Data Sources
The preceding code takes a few seconds to start, as the GetdataSources() method is fairly lengthy. After it completes, however, you will have a fully populated DataTable containing a list of data sources available for the given data provider (in this case, System.Data.SqlClient).