Enumerate the ALL SQL Server Instances in Network
In this article I will teach you how to get names and all other information of sql server instances that are in network.
In this article I will teach you how to get names and all other information of
sql server instances that are in network.
This type of coding will help you in situation where you want to show selection
for the user what sqlserver instance he want to connect to.
For getting all instances of the sql server running on network computers we are
going to us namespace
Import the namespace by writing statement
Now we can get all the instance information in DataTable by executing the method
GetDataSources() of the
So simply we will write the code.
Like below to retrieve the data table containing information about all the
instances of slqserver. Then we can manipulate that datatable to show
information as our project requirement.
I have setup GUI like below as I want to show all the information like below
private void Form1_Load(object
sender, EventArgs e)
/* get data sources */
DataTable dt =
/* Do whatever you
want to do with that table; */
dr in dt.Rows)
dataGridView1.DataSource = dt;
As you can see we can get more information not only name of the sql server
And version also
Just two likes of code and you have enumerated all the instances of the
sqlserver instances in the network
Article teaches how to enumerate Sqlserver instances in the network