Would anyone happen to know how I can return a list of database servers on the visible windows network? (Much like the windows network searching drop down menu in most of MS's apps.)
I 'm trying to provide the user with a list of database servers on the local network (in a treeview, etc.). After the user picks the server, the app would try to inventory it's databases and add them as child nodes to the parent server node.
Scott LyslePosted Nov 19, 2007, 3:50 AM
If you add a reference to SQLDMO (COM tab under add references) and use something like this you should be able to get a list of SQL Servers running on your network added to your treeview:
this.treeView1.Nodes.Clear(); TreeNode node = treeView1.Nodes.Add("SQL Servers"); // create an application class SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass(); // get the sql servers SQLDMO.NameList servers = sqlApp.ListAvailableSQLServers(); try { // add the servers to the treeview for (int i = 0; i < servers.Count; i++) { object thisServer = servers.Item(i + 1); if (thisServer != null) { node.Nodes.Add(thisServer.ToString()); } } } catch { } // open up the treeview this.treeView1.ExpandAll();