当前位置: 代码迷 >> ASP >> ASP.NET获取MS SQL Server装配实例
  详细解决方案

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

热度:47   发布时间:2013-03-17 13:48:31.0
ASP.NET获取MS SQL Server安装实例
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"]));
        }
    }

  相关解决方案