Обновление устройства подписчика

Для изменения данных о существующем устройстве подписчика в базе данных экземпляра служб Notification Services используйте метод Update класса SubscriberDevice. В примерах ниже показано, как обновить устройство подписчика с помощью управляемого кода и с помощью Microsoft Visual Basic Scripting Edition (VBScript) для демонстрации взаимодействия COM.

Пример управляемого кода

В следующем примере кода показано, как использовать в управляемом коде объект SubscriberDevice для обновления устройства подписчика.

string instanceName = "Tutorial";

// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);

// Create the SubscriberDevice object.
SubscriberDevice testSubscriberDevice =
    new SubscriberDevice(testInstance);

// Set the subscriber ID and device name
// so that the correct record is updated.
testSubscriberDevice.SubscriberId = "TestUser1";
testSubscriberDevice.DeviceName = "Work e-mail";

// Modify the subscriber device properties 
// and update the record.
testSubscriberDevice.DeviceAddress = "stephanieb@adventure-works.com";
testSubscriberDevice.DeviceTypeName = "e-mail";
testSubscriberDevice.DeliveryChannelName = "FileChannel";
testSubscriberDevice.Update();

Пример взаимодействия COM

В следующем примере кода VBScript показано, как в неуправляемом коде использовать объект SubscriberDevice для обновления устройства подписчика:

Dim testInstance, testSubscriberDevice
const instanceName = "Tutorial"

' Create the NSInstance object.
set testInstance = _
    WScript.CreateObject( _
    "Microsoft.SqlServer.NotificationServices.NSInstance")
testInstance.Initialize instanceName

' Create the SubscriberDevice object.
set testSubscriberDevice = _
    WScript.CreateObject( _
    "Microsoft.SqlServer.NotificationServices.SubscriberDevice")
testSubscriberDevice.Initialize (testInstance)

' Set the subscriber ID and device name
' so that the correct record is updated.
testSubscriberDevice.SubscriberId = "TestUser2"
testSubscriberDevice.DeviceName = "Work e-mail"

' Modify the subscriber device properties 
' and update the record.
testSubscriberDevice.DeviceAddress = "davidb@adventure-works.com"
testSubscriberDevice.DeviceTypeName = "e-mail"
testSubscriberDevice.DeliveryChannelName = "FileChannel"
testSubscriberDevice.Update()

wscript.echo "Subscriber device updated."

См. также

Основные понятия

Создание объекта SubscriberDevice
Добавление устройства подписчика
Удаление устройства подписчика
Заполнение списка каналов доставки

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

NSSubscriberDeviceView

Справка и поддержка

Получение помощи по SQL Server 2005