次の方法で共有


サブスクライバ デバイスの削除

SubscriberDevice クラスの Delete メソッドは、Notification Services データベースの既存のサブスクライバ デバイス レコードを削除します。以下の例では、マネージ コードを使用してサブスクライバ デバイスを削除する方法と、Microsoft Visual Basic Scripting Edition (VBScript) を使用してサブスクライバ デバイスを削除する方法 (COM 相互運用の一例) を示しています。

最後のサブスクライバ デバイスを削除すると、Notification Services では、そのサブスクライバの行はサブスクライバ デバイス テーブルに残りますが、プロパティはすべて NULL に設定されます。

マネージ コードの例

次のコード例は、マネージ コードで 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 deleted.
testSubscriberDevice.SubscriberId = "TestUser1";
testSubscriberDevice.DeviceName = "Work E-mail";

// Delete the device
testSubscriberDevice.Delete();

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 deleted.
testSubscriberDevice.SubscriberId = "TestUser2"
testSubscriberDevice.DeviceName = "Work e-mail"

' Delete the device
testSubscriberDevice.Delete()

wscript.echo "Subscriber device deleted."

参照

概念

SubscriberDevice オブジェクトの作成
サブスクライバ デバイスの追加
サブスクライバ デバイスの更新
配信チャネル一覧の作成

その他の技術情報

NSSubscriberDeviceView

ヘルプおよび情報

SQL Server 2005 の参考資料の入手