SQLDMO failing to enumerate sql servers in vb

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

Anyone know why this would happen... I added a reference to the SQLDMO COM
object, imported it on top of my code.. then this test code fails

Imports SQLDMO

Module Module1

Sub Main()

Dim i As Integer

Dim oNames As SQLDMO.NameList

Dim oSQLApp As SQLDMO.Application

oSQLApp = New SQLDMO.Application

oNames = oSQLApp.ListAvailableSQLServers()

For i = 1 To oNames.Count

Console.WriteLine(oNames.Item(i))

Next i

End Sub

End Module



the error is "An unhandled exception of type 'System.InvalidCastException'
occured in ConsoleApplication1.exe Additional informaiton: QueryInterfacefor
interface SQLDMO.NameList failed."

I had this working in the past, but now it wont work. What could be wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top