刪除訂閱者記錄
Delete 類別的 Subscriber 方法會刪除執行個體資料庫中的現有訂閱者記錄。
重要事項: |
---|
在啟用的 Notification Services 應用程式中,刪除訂閱者記錄會自動刪除關聯於該訂閱者識別碼的所有訂閱者裝置和訂閱。在停用的 Notification Services 應用程式中,刪除訂閱者記錄會導致相關聯的訂閱被遺棄。您應該從您的應用程式中移除被遺棄的訂閱。 |
Managed 程式碼範例
下列程式碼範例顯示如何利用 Managed 程式碼中的 Subscriber 物件刪除訂閱者。
string instanceName = "Tutorial";
// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);
// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);
// Set the subscriber ID so that the correct
// subscriber record is updated.
testSubscriber.SubscriberId = "TestUser1";
// Change subscriber data, then update the database.
testSubscriber.Delete();
COM Interop 範例
下列 Microsoft Visual Basic Scripting Edition (VBScript) 程式碼範例顯示如何利用 Unmanaged 程式碼中的 Subscriber 物件刪除訂閱者:
Dim testInstance, testSubscriber
const instanceName = "Tutorial"
' Create and initialize the NSInstance object.
set testInstance = _
WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.NSInstance")
testInstance.Initialize instanceName
' Create and initialize the Subscriber object.
set testSubscriber = _
WScript.CreateObject( _
"Microsoft.SqlServer.NotificationServices.Subscriber")
testSubscriber.Initialize (testInstance)
' Set the subscriber ID.
testSubscriber.SubscriberId = "TestUser2"
' Delete the subscriber record
testSubscriber.Delete
wscript.echo "Subscriber deleted."
請參閱
概念
建立訂閱者物件
新增訂閱者記錄
更新訂閱者記錄
刪除相關的訂閱資訊
取得訂閱者的裝置及訂閱