PC Review


Reply
Thread Tools Rate Thread

Available SQL Server list

 
 
=?Utf-8?B?RXZhbks=?=
Guest
Posts: n/a
 
      12th Apr 2004
Is there a way to access a list of available sql servers in vb and make a dropdown list?
 
Reply With Quote
 
 
 
 
Manohar Kamath [MVP]
Guest
Posts: n/a
 
      12th Apr 2004
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" <(E-Mail Removed)> wrote in message
news:F6AD9CBB-0396-42C7-B405-(E-Mail Removed)...
> Is there a way to access a list of available sql servers in vb and make a

dropdown list?


 
Reply With Quote
 
=?Utf-8?B?RXZhbks=?=
Guest
Posts: n/a
 
      12th Apr 2004
Got it.
 
Reply With Quote
 
=?Utf-8?B?RXZhbks=?=
Guest
Posts: n/a
 
      12th Apr 2004
Additionally, is there any doc on SQLDemo that you know of?
 
Reply With Quote
 
=?Utf-8?B?RXZhbks=?=
Guest
Posts: n/a
 
      12th Apr 2004
Great - it worked fine - thanks. Now is there a way to list the databases?
 
Reply With Quote
 
Rich Wallace
Guest
Posts: n/a
 
      12th Apr 2004
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" <(E-Mail Removed)> wrote in message
news:817E17AF-5A0A-416C-98C6-(E-Mail Removed)...
> Great - it worked fine - thanks. Now is there a way to list the

databases?


 
Reply With Quote
 
Rich Wallace
Guest
Posts: n/a
 
      12th Apr 2004
Oops....make sure you hit the Master database

SELECT Name FROM Master..sysdatabases


"EvanK" <(E-Mail Removed)> wrote in message
news:817E17AF-5A0A-416C-98C6-(E-Mail Removed)...
> Great - it worked fine - thanks. Now is there a way to list the

databases?


 
Reply With Quote
 
Manohar Kamath [MVP]
Guest
Posts: n/a
 
      12th Apr 2004
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" <(E-Mail Removed)> wrote in message
news:817E17AF-5A0A-416C-98C6-(E-Mail Removed)...
> Great - it worked fine - thanks. Now is there a way to list the

databases?


 
Reply With Quote
 
=?Utf-8?B?RXZhbks=?=
Guest
Posts: n/a
 
      21st Apr 2004
It seems that when I install this application using the listavailableqlservers function I get an unhandled exception error. I tried a TRY statement surrounding it but to no avail. ANy suggestions?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you get a list of files from server folder to display on in a list control maglev_now@yahoo.com Microsoft ASP .NET 4 20th Oct 2006 01:39 PM
Intigrate Server file system folder list with Exchange folder list =?Utf-8?B?YnVzdGVy?= Microsoft Outlook Discussion 2 15th Feb 2005 10:19 PM
Can't remove old server from server list in active Directory Chris Clarke-Williams Microsoft Windows 2000 Active Directory 8 7th Jul 2004 09:42 AM
Server list Kurt Microsoft VB .NET 5 22nd Apr 2004 09:28 PM
server list not available Brice Microsoft Windows 2000 Networking 0 21st Nov 2003 10:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:12 AM.