Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting SQL Servers
Message
From
12/02/1999 11:32:12
Bob Tracy
Independent Consultant
Driftwood, Texas, United States
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00186452
Message ID:
00187051
Views:
31
>>Does anyone know how to detect the active SQL Servers in a domain? In SQL Server you can show the active servers in the dialog used for registering server groups so there must be an API call somewhere. TIA
>
>You might look into using WNetOpenEnum() and WNetEnumResource() - I haven't tried finding SQL Server instances with it, so I don't know what would be involved in isaolating them in the list of all available shared resources on a given network.

Thanks for the suggestion but I found a SQL-DMO way while researching those API calls. It's a lot easier than I expected:

oSQL = CREATEOBJECT('SQLOLE.SQLServer')
oSQL.Disconnect
oSQL.Connect('satcim')
oApp = oSQL.Application
oApp.ListAnnouncedNetWorkSQLServers()
lnCnt = oApp.ListAnnouncedNetworkSQLServers().Count
FOR n = 1 TO oApp.ListAnnouncedNetworkSQLServers().Count
? oApp.ListAnnouncedNetworkSQLServers().Item(n)
ENDFOR
oSQL.DisConnect
oApp.Quit
Release oApp,oSQL

I haven't looked too hard at SQL-DMO in the past, but I think I'll see what else it will . Looks interesting!
Bob Tracy

Never engage in a battle of wits if you're only half armed.
Previous
Reply
Map
View

Click here to load this message in the networking platform