ASP.NET获取MS SQL Server安装实例

2013 年 8 月 7 日5140

 [csharp]

  View Code

  protected void Page_Load(object sender, EventArgs e)

  {

  DataTable dataTable = SqlDataSourceEnumerator.Instance.GetDataSources();

  foreach (DataRow dr in dataTable.Rows)

  {

  if (string.IsNullOrEmpty(dr["InstanceName"].ToString()))

  this.DropDownListInstance.Items.Add(string.Concat(dr["ServerName"]));

  else

  this.DropDownListInstance.Items.Add(string.Concat(dr["ServerName"], "\", dr["InstanceName"]));

  }

  }

本文关键词:ASP.NET

0 0