473,322 Members | 1,314 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,322 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 2013
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.