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


Instance Class

Represents an instance of Notification Services.

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

Синтаксис

'Декларация
Public NotInheritable Class Instance
    Inherits NamedSmoObject
public sealed class Instance : NamedSmoObject
public ref class Instance sealed : public NamedSmoObject
public final class Instance extends NamedSmoObject
public final class Instance extends NamedSmoObject

Замечания

Изменения текста14 апреля 2006 г.

Notification Services instances host Notification Services applications and define instance-wide settings, such as the database server, custom delivery protocols, and delivery channels, which represent delivery endpoints.

You can use Instance objects to define new instances or to manage existing instances. To define a new instance, you set its properties and then use the Create method. To manage an existing instance, you get a reference to an existing instance via a NotificationServices object.

When using SQL Server Authentication with a NotificationServices object, you use a Server object to obtain a NotificationServices reference, and then use this reference to get a Notification Services instance. When creating an instance of the Server object, you can specify a ServerConnection object that uses a SqlConnection object.

If you are using SQL Server Authentication to call instance and application management methods such as Create, Update, Drop, Enable, or Disable, the SqlConnection must not already be open.

Make sure the SqlConnection is not opened before the Server object instance is created, or else use another ServerConnection constructor that does not use a SqlConnection object.

Inheritance Hierarchy

System.Object
   Microsoft.SqlServer.Management.Smo.SmoObjectBase
     Microsoft.SqlServer.Management.Smo.SqlSmoObject
       Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Nmo.Instance

Пример

The following examples show a minimum instance configuration using Notification Services Management Objects (NMO):

Instance emptyInstance = new Instance(notificationServices, 
    instanceName);

DeliveryChannel fileChannel = new DeliveryChannel(
    emptyInstance, "FileChannel");
fileChannel.ProtocolName = "File";

DeliveryChannelArgument fileNameArg = 
    new DeliveryChannelArgument(fileChannel, "FileName");
fileNameArg.Value = sampleDirectory + 
    @"\Notifications\FileNotifications.txt";

fileChannel.DeliveryChannelArguments.Add(fileNameArg);
emptyInstance.DeliveryChannels.Add(fileChannel);
Console.WriteLine("Delivery channel added.");

Application emptyApp = ConfigureApplication(emptyInstance);

emptyInstance.Applications.Add(emptyApp);

Console.WriteLine("Application added.");
Dim emptyInstance As Instance = _
    New Instance(notificationServices, instanceName)

Dim fileChannel As DeliveryChannel = _
    New DeliveryChannel(emptyInstance, "FileChannel")
fileChannel.ProtocolName = "File"

Dim fileNameArg As DeliveryChannelArgument = _
    New DeliveryChannelArgument(fileChannel, "FileName")
fileNameArg.Value = sampleDirectory + _
    "\Notifications\FileNotifications.txt"

fileChannel.DeliveryChannelArguments.Add(fileNameArg)
emptyInstance.DeliveryChannels.Add(fileChannel)
Console.WriteLine("Delivery channel added.")

Dim emptyApp As Application = _
    ConfigureApplication(emptyInstance)
emptyInstance.Applications.Add(emptyApp)
Console.WriteLine("Application added.")

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

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 Members
Microsoft.SqlServer.Management.Nmo Namespace

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

Настройка экземпляров служб Notification Services
NotificationServicesInstance Element (ICF)