C# - Finding SQL Server Data Sources and Databases
For those exploring how to finding data sources, database names, etc - using C#, you can do the following: // Retrieve the enumerator instance, and then retrieve the data sources. SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance; DataTable dtDatabaseSources = instance.GetDataSources(); // Populate the data sources into DropDownList. foreach (DataRow row in dtDatabaseSources.Rows) if (!string.IsNullOrWhiteSpace(row["InstanceName"].ToString())) cboDatasources.Items.Add(row["ServerName"].ToString() + "\\" + row["InstanceName"].ToString()); The code above however, did not show the local instances of SQL Server 2008 R2. So, to acquire your local instances as well, you will need to use the SMO ManagedComputer object, which provides an interface to the WMI Provider for Configuration Management. You will need to add the following references to the project (using VS2010), in C:\Program Files...