无为清净楼资源网 Design By www.qnjia.com
 
using System;
using System.Data.Sql;
using System.Text;

namespace AllSqlServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //SQLDMO.NameList names;
            //SQLDMO.ApplicationClass ac = new SQLDMO.ApplicationClass();
            //names = ac.ListAvailableSQLServers();
            //string[] serverList = new string[names.Count];
            //for (int i = 0; i < serverList.Length; i++)
            //{
            //    serverList[i] = names.Item(i);
            //}
            //foreach (string str in serverList)
            //{
            //    Console.WriteLine(str);
            //}

            SqlDataSourceEnumerator instance =SqlDataSourceEnumerator.Instance;
            System.Data.DataTable table = instance.GetDataSources();

            DisplayData(table);

            Console.ReadLine();
        }

        private static void DisplayData(System.Data.DataTable table)
        {
            foreach (System.Data.DataRow row in table.Rows)
            {
                Console.WriteLine("服务器名 = {0}", row["ServerName"]);
                Console.WriteLine("实例名 = {0}", row["InstanceName"]);
                Console.WriteLine("是否集成验证 = {0}", row["IsClustered"]);//即Windows身份验证和SQL Server验证
                Console.WriteLine("版本 = {0}", row["Version"]);//8.*是SQL 2000,9.*是SQL 2005
                Console.WriteLine("============================");
            }
        }
    }
}

文章引用自: 
标签:
C#,局域网,SQL,Server,服务器

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com