Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL-DMO doesn't return Server available
Message
De
20/01/2009 11:16:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/01/2009 16:20:39
Peter Wagner
Point Informática Ltda.
Limeira, Brésil
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Application:
Desktop
Divers
Thread ID:
01375255
Message ID:
01375500
Vues:
31
>Hi, I attempt to discover if a SQL Server is available in the network, so I run the code below, but it returns that there is no SQL Server there, but I have a SQl Server in the PC and I can connect to it.
>What im missing here?
>Thanks in Advance
>
>Peter
>
>
>LOCAL oSQLDMO AS SQLDMO.SQLserver
>LOCAL oNames AS SQLDMO.NameList
>oSQLDMO = CREATEOBJECT("SQLDMO.SQLserver")
>oNames = oSQLDMO.APPLICATION.ListAvailableSQLServers()
>FOR ix=1 TO oNames.COUNT
> ? oNames.ITEM[ix]
>ENDFOR
>
Peter,
It wouldn't work. Neither would some APIs (one is used by VFP data explorer). Those all assume SQL2000 and fail with 2005/2008 servers unless you explicitly change driver name.

These work for installed instances and registered servers. I haven't seen a reliable way to discover what is available on a network:
Local oSQLDMO2 as SQLDMO.SQLserver2,;
  oSQLDMO As SQLDMO.SQLserver,;
  oSG As SQLDMO.ServerGroup,;
  oSrv As SQLDMO.RegisteredServer

** get installed instances
oSQLDMO2 = Createobject("SQLDMO.SQLserver2")
oNames2 = oSQLDMO2.ListInstalledInstances()
For ix=1 To oNames2.Count
  ? oNames2.Item[ix]
Endfor
? '***************'

*** Get registered servers
oSQLDMO = Createobject("SQLDMO.SQLserver")
? 'SQL server groups count:', oSQLDMO.Application.ServerGroups.Count
For Each oSG In oSQLDMO.Application.ServerGroups
  ? Textmerge('SQL server group name:[<<oSG.Name>>] have <<oSG.RegisteredServers.Count>> registered servers')
  For Each oSrv In oSG.RegisteredServers
    ? oSrv.Name
  Endfor
Endfor
PS: MS documented that SQLDMO (and probably the APIs it uses) would be dropped in future SQL server versions. SQL SMO is the way to go but I don't know if there is a way to use it from VFP.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform