Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 List SQL servers when not on a network.

Author  Topic 

philjeary
Starting Member

13 Posts

Posted - 2005-01-13 : 11:47:26
I've seen lots of posts and webpages about how to list SQL servers, but none of them seem to work when not on a network.

Our users can be on a network, but they may be installing our product using MSDE and therefore possibly won't be on a network. The only method of listing servers I've found that doesnt apparently have a problem when not on a network is NetServerEnum, but this doesnt work on all operating systems.

FYI both OSQL/ISQL in does and SQLDMO return no servers if you unplug the network cable. I should also mention that i'm after a VB solution if possible (but any suggestions will do at this time!).

Any help would be much appreciated as this has been winding me up for months!


Regards,
Phil

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-01-13 : 13:06:56
LOL
quote:

FYI both OSQL/ISQL in does and SQLDMO return no servers if you unplug the network cable.





Go to Top of Page

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-01-13 : 13:10:38
If your after the MSDE from an install you could use (local) in your app connection... This will still present problems if they already have MSDE installed to a different instance... Provide them with a setup box that populates a default that can be controlled by the user and capture that in an ini file... read from their when running your app.

Go to Top of Page

philjeary
Starting Member

13 Posts

Posted - 2005-01-14 : 04:23:57
The user can use any version of SQL either locally or on the network. My app has the option to install MSDE which it installs as Computername\SPIRIT, so as a shoddy workround, if its blank I can default to computername\SPIRIT, but that opens up more issues such as "what if the instance of SQL isnt running".

Either way I need to have a list so I can populate a dropdown as non technical people (reps, lol) will be using it.

It must be possible somehow as the sqlmangr.exe program does it - but i'm guessing microsoft haven't shared their code :(

Regards,
Phil
Go to Top of Page

philjeary
Starting Member

13 Posts

Posted - 2005-01-14 : 06:31:11
I found an example that works here: http://sqldev.net/misc/ListSQLSvr.htm
......but its in C++

Know any good C++ to VB converters so I can put the code into my .exe?



Regards,
Phil
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-01-14 : 08:36:35
Yeah...don't. Tweak the C++ code so that it can be compiled as an ActiveX object instead. Then you can instantiate and call it from VB or any other COM consumer.

I'm pretty certain all of the info you might need would be in the registry somewhere, even the names of non-running instances. And any mechanism that can give you the list of runnable services on the machine would give you SQL Server too (this could be as simple as running "net start" and getting the results)
Go to Top of Page

philjeary
Starting Member

13 Posts

Posted - 2005-01-14 : 11:18:42
Thanks for your reply Rob. I did initially think of using the C++ as an active x dll but don't know near enough c++ to do the task.
I didnt realise it was all stored in registry, I think i'll have a look at that before I attempt any C++

Thanks for the tip.

Regards,
Phil
Go to Top of Page

philjeary
Starting Member

13 Posts

Posted - 2005-01-17 : 06:48:45
A very kind programmer has converted it for me :)

Regards,
Phil
Go to Top of Page
   

- Advertisement -