473,796 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4555
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.Sql Client 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.co m

"John Barr" <jb***@toobrand s.com> wrote in message
news:D3******** *************** ***********@mic rosoft.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***@toobrand s.com> wrote in message
news:D3******** *************** ***********@mic rosoft.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.LocalMa chine.OpenSubKe y( "HKEY_LOCAL_MAC HINE\\SOFTWARE\ \Microsoft\\M
icrosoft SQL Server" );
Console.WriteLi ne(Convert.ToSt ring(RK.GetValu e("InstalledIns tances")));

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
2783
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 as member variables. So including a forward declaration doesnt help, does it? Faced with these, I had the following options: -Include the appropriate header in the header file that contains the class definition that has a member variable that is...
8
12112
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 combobox. What is the solution? Thank you in advance.
3
2046
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 anyone know of a way to do this ? Any URLs, code snippets, etc ?
3
1799
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 with valuemember wet to -1. This is showing up at the bottom of the list. I want it to show at the top of the listing. How can I do that? Thanks, Alpha
5
13312
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 was, but i haven't had any luck. In Java you got the instanceOf() operator to do this. What's the equilant in VB.net?
4
2010
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 interface like the OpenFileDialog that has a pulldown(at the top of the dialog) to allow a user to navigate a directory/folder selection.
2
1740
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
1352
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 powerful but I'm having a bit of a problem conceptually. I was hoping someone might be able to shed some light on creating this object and assigning it in the manner. Also how would I reference this object by name after it is created in this...
1
1490
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. I have already typed in each county's name as the title for each unique movie clip and instance of each movieclip on the stage (approx. 3,100 times 2). I would prefer to avoid listing all the counties in my script by simply calling to the instance...
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.