RegisteredServer Object
后续版本的 Microsoft SQL Server 将删除该功能。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。
The RegisteredServer object exposes the attributes of a single, registry-listed instance of Microsoft SQL Server.
Properties
注释
SQL Distributed Management Objects (SQL-DMO) applications can maintain lists of some or all instances of SQL Server in an organization in the registry of the operating system. The lists establish categories for instances of SQL Server.
For example, to group and view servers by division in a SQL-DMO application, SQL-DMO would represent each division as a ServerGroup object. The division's ServerGroup name is maintained by SQL-DMO as a Windows registry key. Within this registry entry, separate keys list each instance of SQL Server in the division. The list of these keys forms the members of the SQL-DMO RegisteredServers collection, while each key's data is exposed by a RegisteredServer object.
With the RegisteredServer object, you can:
Create a Windows registry entry that lists an organization server.
Remove a Windows registry entry that lists an instance of SQL Server.
Manage a Windows registry entry that lists an instance of SQL Server by setting connection-validation attributes.
The Name property of the RegisteredServer object refers to the instance of SQL Server registered. SQL-DMO does not attempt to validate the Name property value when registering an instance of SQL Server. The RegisteredServer object Name property is validated when the object is used in an attempt to connect to an instance of SQL Server.
After an instance of SQL Server is registered, SQL-DMO uses the properties of the registered server when connecting and when attempting to reconnect after a connection failure. For example, SQL-DMO ignores the szLogin and szPassword parameters of the Connect method of the SQLServer object when that object references an instance of SQL Server registered to use Windows Authentication Mode.
To create a registry entry listing an instance of SQL Server
Create a RegisteredServer object.
Set the properties determining connection validation appropriately. For example, set the UseTrustedConnection property to TRUE to enable Windows Authentication Mode.
Add the RegisteredServer object to the RegisteredServers collection of the ServerGroupobject of an Application object.