开发者

Get list of all sql servers installed in the system

I am trying to get list of all SQL Servers installed in the machine 开发者_StackOverflow中文版and populate them in a drop downlist. I have searched in google and tried the following:

using System;
using System.Data;
using Microsoft.SqlServer.Management.Smo;

namespace SMOTest
{
    class Program
    {
        static void Main()
        {
           DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
           if (dt.Rows.Count > 0)
           {
              foreach (DataRow dr in dt.Rows)
              {
                 Console.WriteLine(dr["Name"]);
              }
           }
        }
    }
}

However I didn't find a reference for Microsoft.SqlServer.Management.Smo;

What is the best way to get all the sqlserver names and populate it in a drop down list?


If you dont find it than you can google it and than you can pass the reference of it the simplest way to achive it.

Check this answer : http://social.msdn.microsoft.com/forums/en-US/sqlsmoanddmo/thread/883d89df-fb19-4b04-ab83-1006a3559476/

Do Install : Microsoft SQL Server 2008 Feature Pack, October 2008

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜