Link to home
Start Free TrialLog in
Avatar of Johnjces
JohnjcesFlag for United States of America

asked on

Find MS SQL Servers on a network, How To

I have used the following code to find MS SQL Servers on a LAN.

procedure GetAvailableServers (Var slServerList : TStringList);
var
objList : OleVariant;
iCount: Integer;
obj : OleVariant;
begin
obj := CreateOleObject('SQLDMO.Application');
objlist := obj.ListAvailableSQlServers;
for iCount := 1 to objList.Count  do
  slServerList.Add(objList.Item(iCount));
end;

It works on my PC only which is the development PC. Other PCs running Win 2000 error with "Invalid Class String" and I am pretty certain it is erroring in the main line,
obj := CreateOleObject('SQLDMO.Application');

Is there another method for locating running MS SQL Servers on a LAN without using comobj OR what dll do I need to copy to the other PCs and register for this code to work and not error. All pcs are using MS SQL server and can connect to MS SQL server just fine.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of BlackTigerX
BlackTigerX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Johnjces

ASKER

Well I did a search on this site and found a lot of other stuff but not what I was looking for!

Thanks for searching!
Avatar of BlackTigerX
BlackTigerX

all I searched for was:

Find SQL Servers

and checked "Restrict to this Topic Area"
first hit was the right answer... I knew it was here somewhere