Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sqldmo
Message
From
23/09/2002 12:16:34
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:
00703421
Views:
12
Cathi,

Thanks for the response. I do have the reference to the MS SQLDMO Object Library and I still get the same results. Do you have any other suggestions?

Thanks

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
Thanks

Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform