共用方式為


更新訂閱者裝置

請利用 SubscriberDevice 類別的 Update 方法,來修改 Notification Services 執行個體資料庫中現有的訂閱者裝置資料。下列範例顯示如何利用 Managed 程式碼來更新訂閱者裝置,利用 Microsoft Visual Basic Scripting Edition (VBScript) 來說明 COM Interop。

Managed 程式碼範例

下列程式碼範例顯示如何在 Managed 程式碼中,利用 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 Interop 範例

下列 VBScript 範例顯示如何在 Unmanaged 程式碼中,利用 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 協助