Поделиться через


Instance.RegisterLocal Method (String, String)

Registers the instance of Notification Services locally and, if the Microsoft Windows service does not exist, installs the Windows service that runs the Notification Services engine.

Пространство имен: Microsoft.SqlServer.Management.Nmo
Сборка: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Синтаксис

'Декларация
Public Sub RegisterLocal ( _
    serviceUserName As String, _
    servicePassword As String _
)
public void RegisterLocal (
    string serviceUserName,
    string servicePassword
)
public:
void RegisterLocal (
    String^ serviceUserName, 
    String^ servicePassword
)
public void RegisterLocal (
    String serviceUserName, 
    String servicePassword
)
public function RegisterLocal (
    serviceUserName : String, 
    servicePassword : String
)

Параметры

  • serviceUserName
    A String specifying the Windows user name for the instance of Notification Services.
  • servicePassword
    A String specifying the password for the user.

Замечания

ms199821.note(ru-ru,SQL.90).gifВажно!
Secure any executable and source code that contains passwords.

For information about the permissions required by the Windows service, see Настройка учетных записей Windows для экземпляра служб Notification Services and Настройка разрешений SQL Server для экземпляра служб Notification Services.

Пример

The following examples show how to call a method that configures an instance and its applications, and then create, register, and enable that instance:

// Set Database Engine instance and 
// Notification Services object
server = new smo.Server(sqlServer);
notificationServices = server.NotificationServices;

// Determine if the instance already exists. If so, exit.
if (server.NotificationServices.Instances.Contains(
    instanceName))
{
    Console.WriteLine("Instance exists and will be deleted.");
    myInstance = notificationServices.Instances[instanceName];
    DeleteInstance(myInstance);
}

// Call ConfigureInstance method to configure the instance
// and define the application(s).
myInstance = ConfigureInstance(notificationServices);

// Create the instance
Console.WriteLine("Creating instance...");
myInstance.Create();

//Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...");
myInstance.Export(@"C:\NS\Full", true);

// Register and enable the instance
Console.WriteLine("Registering instance...");
myInstance.RegisterLocal(serviceUserName, servicePassword);
Console.WriteLine("Enabling instance...");
myInstance.Enable();
Console.WriteLine("Done.");
' Set Database Engine server and 
' Notification Services object
server = New smo.Server(sqlServer)
notificationServices = server.NotificationServices

' Determine if the instance already exists. If so, exit.
If server.NotificationServices.Instances.Contains( _
  instanceName) Then
    Console.WriteLine( _
        "Instance exists and will be deleted.")
    myInstance = notificationServices.Instances( _
        instanceName)
    DeleteInstance(myInstance)
End If

' Call ConfigureInstance method to configure the instance
' and define the application(s).
myInstance = ConfigureInstance(notificationServices)

' Create the instance
Console.WriteLine("Creating instance...")
myInstance.Create()

'Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...")
myInstance.Export("C:\NS\Full", True)

' Register and enable the instance
Console.WriteLine("Registering instance...")
myInstance.RegisterLocal(serviceUserName, servicePassword)
Console.WriteLine("Enabling instance...")
myInstance.Enable()
Console.WriteLine("Done.")

Синхронизация потоков

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Платформы

Платформы разработки

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

Целевые платформы

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

См. также

Справочник

Instance Class
Instance Members
Microsoft.SqlServer.Management.Nmo Namespace

Другие ресурсы

Защита файлов и папок
Развертывание служб Notification Services
Обновление сведений реестра