473,395 Members | 1,689 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,395 software developers and data experts.

Available SQL Server list

Is there a way to access a list of available sql servers in vb and make a dropdown list?
Nov 20 '05 #1
7 2015
You need to import SQLDMO in your project. The following function adds the
list of servers to a combo box - cboServers and returns the count:

Imports SQLDMO

.....

Private Function LoadSQLServerList() As Integer
Dim serverIndex As Integer
Dim sqlServers As SQLDMO.NameList
Dim sqlServer As Object

' Get a list of servers
sqlServers = New SQLDMO.Application().ListAvailableSQLServers()

' Iterate through the server names, and add it to the combobox
For Each sqlServer In sqlServers
If Not sqlServer Is Nothing Then
cboServers.Items.Add(sqlServer)
End If
Next

' Send back the count of servers
LoadSQLServerList = cboServers.Items.Count
End Function

Hope that helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"EvanK" <an*******@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
Is there a way to access a list of available sql servers in vb and make a

dropdown list?
Nov 20 '05 #2
Got it.
Nov 20 '05 #3
Additionally, is there any doc on SQLDemo that you know of?
Nov 20 '05 #4
Great - it worked fine - thanks. Now is there a way to list the databases?
Nov 20 '05 #5
You could create a method/routine that would return the results of:

SELECT Name FROM sysdatabases ORDER BY <your choice, Name, ID>

and fill another combobox with it..or listbox...or wheva!

HTH
-Rich

"EvanK" <an*******@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Great - it worked fine - thanks. Now is there a way to list the

databases?
Nov 20 '05 #6
Oops....make sure you hit the Master database

SELECT Name FROM Master..sysdatabases
"EvanK" <an*******@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Great - it worked fine - thanks. Now is there a way to list the

databases?
Nov 20 '05 #7
Continuing the previous example:

Dim sqlServer As SQLDMO.SQLServer
Dim sqlDB As Object

sqlServer = New SQLDMO.SQLServer()
Try
' Connect to your database with userID and password
sqlServer.Connect(cboServers.Text, txtUserID.Text,
txtPassword.Text)

' Check for database names in the server
' This loop adds the database name to another combobox
For Each sqlDB In sqlServer.Databases
If Not sqlDB.Name Is Nothing Then
cboDatabases.Items.Add(sqlDB.name)
End If
Next
Catch Exp As Exception
MsgBox(Exp.ToString)
End Try
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"EvanK" <an*******@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Great - it worked fine - thanks. Now is there a way to list the

databases?
Nov 20 '05 #8

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

Similar topics

1
by: Chad Lupkes | last post by:
Hi everyone, I am looking for a way to determine for myself what scripts are available to use on a particular server. It has been suggested to me that I should "see if I can find an ASP that will...
1
by: Tony Archer | last post by:
I am trying to build a site for a group which already has a hosting company. I would like to try to find out which objects are available for use to me. I do not have admin access to the NT box. ...
0
by: Nikki Locke | last post by:
Archive-name: C++-faq/libraries/part1 Comp-lang-c++-archive-name: C++-faq/libraries/part1 Available C++ Libraries FAQ =========================== Introduction ~~~~~~~~~~~~ Dos and don'ts -...
6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
8
by: EvanK | last post by:
Is there a way to access a list of available sql servers in vb and make a dropdown list?
4
by: comp.lang.php | last post by:
I wrote my own version of memory_get_usage() if that function is not available: if (!function_exists('memory_get_usage')) { /** * Determine the amount of memory you are allowed to have * *...
0
by: mandarkraftware | last post by:
Hi All, Let me present you with list of consultants currently available. Name / Job Title Summary Ramchandran/Java · 7+ years experience in the field of Software Development. · Expertise...
1
by: Sachin | last post by:
Hi All, Let me present you with list of consultants currently available. Name / Job Title Summary Ramchandran/Java · 7+ years experience in the field of Software Development. · Expertise...
2
by: querry | last post by:
Hi all, I am trying to get a list of all the available sql servers and then populate them in a combo box. I do this with the following code taken from...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.