Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sqldmo
Message
From
23/09/2002 10:19:44
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
Sqldmo
Miscellaneous
Thread ID:
00703368
Message ID:
00703368
Views:
52
Hello,

I am creating a program that documents the tables and fields in a database. I want the user to be able to select the name of the server from a combobox. The combobox should be filled with all available SQL servers. I found some code from a sample on this site and it doesn't work. The error message and code are below. Does anyone know what is wrong?

Error:
An unhandled exception of type 'System.InvalidCastException' occurred in MSDEManager.exe

Additional information: QueryInterface for interface SQLDMO.NameList failed.

Code:
Private Sub GetSqlServers()
Dim sqlApp As SQLDMO.Application = New SQLDMO.ApplicationClass()
Dim listServers As SQLDMO.NameList = sqlApp.ListAvailableSQLServers()
Dim server As Object

Dim root, node As TreeNode

root = Me.treeServers.Nodes(0)
For Each server In listServers
node = New TreeNode(server.ToString(), ICON_ServerDisconnected, ICON_ServerDisconnected)
node.Tag = "Server"
root.Nodes.Add(node)
Next server

If root.GetNodeCount(False) = 0 Then
node = New TreeNode("", ICON_ServerDisconnected, ICON_ServerDisconnected)
node.Tag = "Nothing"
root.Nodes.Add(node)
End If

root.Expand()
SetStatus("Connected", "Ok", "Ready")
End Sub
Thanks

Jim
Next
Reply
Map
View

Click here to load this message in the networking platform