获取数据库服务名称
public static List<string> GetSqlServerNames()
{
List<string> serverNames = new List<string>();
DataTable table = SqlClientFactory.Instance.CreateDataSourceEnumerator().GetDataSources();
foreach (DataRow dr in table.Rows)
{
string serverName = string.Format("{0}\\{1}", dr["ServerName"], dr["InstanceName"]);
serverNames.Add(serverName);
}
return serverNames;
}