Loading database into combobox as well server name that are available...
Import reference:
//This is available in sql sever SDK Folder
Microsoft.SqlServer.ConnectionInfo
Microsoft.SqlServer.Smo
//Use namespace to import.
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
Declare Object of Server Class
Code in load event of form:
//datatable object
DataTable dt = SmoApplication.EnumAvailableSqlServers(true);
if (dt.Rows.Count > 0)
{
// Loop through each server in the DataTable
foreach (DataRow dr in dt.Rows)
{
//cmbsrv_name is name of combo box in //which all server name will be loaded..
cmbsrv_name.Items.Add(dr["Name"]);
Join the conversation! Your thoughts help the community grow.