Share via


Instance.Enable Method

Sets the status of the instance to Enabled.

Espacio de nombres: Microsoft.SqlServer.Management.Nmo
Ensamblado: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Sintaxis

'Declaración
Public Sub Enable
public void Enable ()
public:
void Enable ()
public void Enable ()
public function Enable ()

Notas

When you create a Notification Services instance, it is disabled. Enabling the instance enables all instance and application components, which allows event collection, notification generation, notification distribution, and subscription management.

The Notification Services engine queries the database for the status of its components every 30 seconds. Until the engine picks up the status change, engine components show a status of Enable Pending.

Ejemplo

The following examples show how to create, register, and enable an instance of Notification Services:

// 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.")

Seguridad para subprocesos

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.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

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

Otros recursos

Habilitar y deshabilitar instancias, aplicaciones o componentes
Ver el estado de instancias, aplicaciones y componentes