Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sqldmo
Message
 
To
23/09/2002 14:45:15
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
General information
Forum:
ASP.NET
Category:
Databases
Title:
Re: Sqldmo
Miscellaneous
Thread ID:
00703368
Message ID:
00703519
Views:
22
Good to hear it was a simple fix.

>Cathi,
>
> Just to let you know that I got it to work. All I did was install SP2 for SQL 2k
>
>Jim
>
>>Hi Jim,
>>
>>I just tried the following code and a messagebox is returned for each server found. Make sure you set a reference to the COM object called "Microsoft SQLDMO Object Library":
>>
>>
>>Dim sqlApp As SQLDMO.Application = New SQLDMO.ApplicationClass()
>>Dim listServers As SQLDMO.NameList = sqlApp.ListAvailableSQLServers()
>>Dim server As Object
>>For Each server In listServers
>>    MessageBox.Show(server.ToString())
>>Next server
>>
>>
>>>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
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform