private void button1_Click(object sender, EventArgs e)
                  {
                      DataTable dataSources 
          = SqlClientFactory.Instance.CreateDataSourceEnumerator().GetDataSources();

                      DataColumn column 
          = dataSources.Columns["InstanceName"];
                      DataColumn column2 
          = dataSources.Columns["ServerName"];

                      DataRowCollection rows 
          = dataSources.Rows;
                      List
          <string> Serverlist = new List<string>();
                      
          string array = string.Empty;
                      
          for (int i = 0; i < rows.Count; i++)
                      {
                          
          string str2 = rows[i][column2] as string;
                          
          string str = rows[i][column] as string;
                          
          if (((str == null|| (str.Length == 0)) || ("MSSQLSERVER" == str))
                          {
                              array 
          = str2;
                              Console.WriteLine(array);
                          }
                          
          else
                          {
                              array 
          = str2 + @"\" + str;
                              Console.WriteLine(array);
                          }

                          Serverlist.Add(array);
                      }

                      Serverlist.Sort();
                  }
          posted on 2011-03-17 14:19 Ying-er 閱讀(571) 評論(0)  編輯  收藏 所屬分類: .Net
          主站蜘蛛池模板: 双城市| 府谷县| 天全县| 海晏县| 遂平县| 榆树市| 泰顺县| 崇仁县| 平远县| 临朐县| 安阳县| 泰州市| 上思县| 连江县| 新疆| 萨嘎县| 收藏| 南江县| 诸暨市| 仁怀市| 色达县| 新泰市| 锡林浩特市| 密云县| 巩义市| 灵丘县| 洪湖市| 富宁县| 永济市| 滨海县| 钦州市| 通海县| 丹凤县| 麻阳| 长乐市| 伊川县| 信阳市| 宜春市| 吉水县| 鹤岗市| 鄯善县|