次の方法で共有


サブスクライバ デバイスの更新

SubscriberDevice クラスの Update メソッドは、Notification Services インスタンス データベース内の既存のサブスクライバ デバイス データを変更するために使用します。以下の例では、マネージ コードを使用してサブスクライバ デバイスを更新する方法と、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 の参考資料の入手