Hi,
I'm trying to list all SQL servers using vb.net.
I have added a refernce to SQLDMO and I am using the following code (which I found off another site).
Dim oDmoApp As New SQLDMO.Application
Dim oDmoList As SQLDMO.NameList
Dim i As Integer
oDmoList = oDmoApp.ListAvailableSQLServers
For i = 1 To oDmoList.Count
Me.ComboBox1.Items.Add(oDmoApp.ListAvailableSQLServers.Item(i))
Next
However, I am receiving the following error:
An unhandled exception of type 'System.InvalidCastException' occured in Myproject.exe
Additional information: QueryInterface for interface SQLDMO.NameList failed.
Does anyone know how to resolve this?
Thanks
Bob
I'm trying to list all SQL servers using vb.net.
I have added a refernce to SQLDMO and I am using the following code (which I found off another site).
Dim oDmoApp As New SQLDMO.Application
Dim oDmoList As SQLDMO.NameList
Dim i As Integer
oDmoList = oDmoApp.ListAvailableSQLServers
For i = 1 To oDmoList.Count
Me.ComboBox1.Items.Add(oDmoApp.ListAvailableSQLServers.Item(i))
Next
However, I am receiving the following error:
An unhandled exception of type 'System.InvalidCastException' occured in Myproject.exe
Additional information: QueryInterface for interface SQLDMO.NameList failed.
Does anyone know how to resolve this?
Thanks
Bob