We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

ListAvailableSQLServers

Thread ID:

Created:

Updated:

Platform:

Replies:

1156 Sep 28,2002 03:45 AM Dec 9,2003 09:09 PM Windows Forms 2
loading
Tags: FAQ
Vipul Bhatt
Asked On September 28, 2002 03:45 AM

'_______________________________________ Dim i As Integer Dim oSQLApp As New SQLDMO.Application() Dim oNames As SQLDMO.NameList oNames = oSQLApp.ListAvailableSQLServers Try oNames = oSQLApp.ListAvailableSQLServers Catch MsgBox(Err.Description) Exit Sub End Try CmbServer.Items.Clear() For i = 1 To oNames.Count CmbServer.Items.Add(oNames.Item(i)) Next i '_________________________________________ this not working. It gives an error saying 'InvaidCastException'. Kindly help.

andy lennard
Replied On March 27, 2003 04:24 PM

Try this it worked on my XP System under SQL 2000 personal server connected to win 2k server with sql 2000. Dim oSQLDMOApplication, oServersNameList oSQLDMOApplication = CreateObject("SQLDMO.Application") oServersNameList = oSQLDMOApplication.ListAvailableSQLServers() Dim i For i = 1 To oServersNameList.Count MyServerNames.Items.Add(oServersNameList.Item(i)) Next i oSQLDMOApplication = Nothing The difference between this and your code being the use of create object. When I used NEW I got the same result as you. Hope this helps Andrew. > '_______________________________________ > Dim i As Integer > Dim oSQLApp As New SQLDMO.Application() > Dim oNames As SQLDMO.NameList > oNames = oSQLApp.ListAvailableSQLServers > Try > oNames = oSQLApp.ListAvailableSQLServers > Catch > MsgBox(Err.Description) > Exit Sub > End Try > CmbServer.Items.Clear() > For i = 1 To oNames.Count > CmbServer.Items.Add(oNames.Item(i)) > Next i > '_________________________________________ > this not working. It gives an error saying 'InvaidCastException'. > Kindly help. >

John Cosmas
Replied On December 9, 2003 09:09 PM

I had a problem using the oSQLDMOApplication.ListAvailableSQLServers method. My XP box returned a "Object required" message. Please help; I need to somehow enumerate my SQL Servers. The registry method is not very practical because there may be servers not listed in my local registry. > Try this it worked on my XP System under SQL 2000 personal server connected to win 2k server with sql 2000. > > Dim oSQLDMOApplication, oServersNameList > oSQLDMOApplication = CreateObject("SQLDMO.Application") > oServersNameList = oSQLDMOApplication.ListAvailableSQLServers() > Dim i > For i = 1 To oServersNameList.Count > MyServerNames.Items.Add(oServersNameList.Item(i)) > Next i > > oSQLDMOApplication = Nothing > > The difference between this and your code being the use of create object. When I used NEW I got the same result as you. Hope this helps > Andrew. > > > '_______________________________________ > > Dim i As Integer > > Dim oSQLApp As New SQLDMO.Application() > > Dim oNames As SQLDMO.NameList > > oNames = oSQLApp.ListAvailableSQLServers > > Try > > oNames = oSQLApp.ListAvailableSQLServers > > Catch > > MsgBox(Err.Description) > > Exit Sub > > End Try > > CmbServer.Items.Clear() > > For i = 1 To oNames.Count > > CmbServer.Items.Add(oNames.Item(i)) > > Next i > > '_________________________________________ > > this not working. It gives an error saying 'InvaidCastException'. > > Kindly help. > > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;