پیدا کردن لیست SQL server های نصب شده در یک شبکه
نویسنده: وحید نصیری
تاریخ: ۱۳۸۷/۰۸/۲۸ ۱۴:۰۴:۳۸
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
using SQLDMO;
using System.Collections.Generic;
public static List<string> GetSQLServersList2()
{
List<string> result = new List<string>();
ApplicationClass sqlApp = new ApplicationClass();
NameList lst = sqlApp.ListAvailableSQLServers();
for (int i = 1; i <= lst.Count; i++)
result.Add(lst.Item(i));
lst = null;
sqlApp = null;
return result;
}
using System.Collections.Generic;
using System.Data;
using System.Data.Sql;
public class CListServers
{
public static List<string> GetSQLServersList()
{
List<string> result = new List<string>();
// Retrieve the enumerator instance and then the data.
var instance = SqlDataSourceEnumerator.Instance;
var table = instance.GetDataSources();
// Display the contents of the table.
foreach (DataRow row in table.Rows)
{
result.Add(string.Format("{0}\\{1}", row[0], row[1]));
}
return result;
}
}
using System.Collections.Generic;
using System.Data;
using Microsoft.SqlServer.Management.Smo;
public class CListServers
{
public static List<string> GetSQLServersListSMO()
{
List<string> result = new List<string>();
DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
result.Add(dr["Name"].ToString());
}
}
return result;
}
}