473,387 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQL instance Listing in ComboBox

Does anyone know how to search for Instances of SQL Server running on your network through code to populate a drop down like is done in the SQL Server Query Analyzer, and then once an instance is selected, list the databases on that Instance?
Nov 15 '05 #1
3 4520
John,

In order to do this, you have a number of options.

To get the list of SQL server instances on the network, you can call the
NetServerEnum function through the P/Invoke layer. It will allow you to
return a list of SQL server instances on your network. Also, you can use
the SQLDMO library through COM interop. There is a COM class that has a
method that will do this (although the name escapes me).

Once you have the names of your SQL servers, you can use the classes in
the System.Data.SqlClient namespace to connect to the database and then
issue queries against the system tables to get the databases on the
instance. Also, you can set a reference to the ADOX library to do the same
thing through an object-oriented model.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Barr" <jb***@toobrands.com> wrote in message
news:D3**********************************@microsof t.com...
Does anyone know how to search for Instances of SQL Server running on your

network through code to populate a drop down like is done in the SQL Server
Query Analyzer, and then once an instance is selected, list the databases on
that Instance?
Nov 15 '05 #2
John Barr <jb***@toobrands.com> wrote in message
news:D3**********************************@microsof t.com...
Does anyone know how to search for Instances of SQL Server running on your

network through code to populate a drop down like is done in the SQL Server
Query Analyzer, and then once an instance is selected, list the databases on
that Instance?

RegistryKey RK;
RK =
egistry.LocalMachine.OpenSubKey( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\M
icrosoft SQL Server" );
Console.WriteLine(Convert.ToString(RK.GetValue("In stalledInstances")));

You do need to parse the value return before populating your list box.
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Mon | last post by:
I am in the process of reorganizing my code and came across and I came across a problem, as described in the subject line of this posting. I have many classes that have instances of other classes...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: David Jacques | last post by:
I am trying to get a list of all files of a certain extension type on disk to do some processing in a loop. The code needs to be portable to UNIX, so I need to use plain c functionality. Does...
3
by: Alpha | last post by:
This is a Window based application. How do I get my combox listing to display in sorted order by DataMember? I inserted a blank row to the dataset table which is the datasrouce for the comboBox...
5
by: Jarod_24 | last post by:
I got a object of type 'Control' passed as a argument to a subroutine of mine. The object is either a Combobox or a TextBox. I thought the .GetType could be used to check what type of object it...
4
by: James Kunicki | last post by:
Hello, I would like to know if anyone as found a way to list a image next to a list box to indicate what type of drive (local or network) and a folder I would like to present in a user...
2
by: DKC | last post by:
Hi All, Is there any way wherein I can get a list of database servers on my local network. Any help appreciated. I am using VB.NET 2003 Thanks DKC
3
by: RSH | last post by:
I am slowly getting the hang of objects and creating my own. I was given some help in assigning an object to a ComboBox collection. I have been looking at it and I get the concept which is very...
1
daJunkCollector
by: daJunkCollector | last post by:
Is there a way that I can have the name of an instance's name appear in a dynamic textfield? I have a map with every county in the USA on it and I want the county's name to display on rollover. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.