日期:2014-05-16  浏览次数:21058 次

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"]));
        }
    }