نوشته شده توسط
azadich
ببخشید یک نمونه میتونید برام بزارید
ممنونم
اینم نمونه کدهای #C در Stackoverflow برای لیست کردن سرورهایی که روی سیستم نصب هستند:
Opera Snapshot_2022-11-16_131854_stackoverflow.com.png
و این هم لیست کردن دیتابیس های یک SQL Server Instance:
public List<string> GetDatabaseList()
{
List<string> list = new List<string>();
// Open connection to the database
string conString = "server=xeon;uid=sa;pwd=manager; database=northwind";
using (SqlConnection con = new SqlConnection(conString))
{
con.Open();
// Set up a command with the given query and associate
// this with the current connection.
using (SqlCommand cmd = new SqlCommand("SELECT name from sys.databases", con))
{
using (IDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
list.Add(dr[0].ToString());
}
}
}
}
return list;
}
البته در مورد کد بالا مطمئن نیستم ولی مورد تائید قرار گرفته:
Opera Snapshot_2022-11-16_132649_stackoverflow.com.png