共用方式為


Subscriber.GetSubscriptions Method

Gets all of the subscriber's subscriptions for the specified subscription class in the specified Notification Services application.

命名空間: Microsoft.SqlServer.NotificationServices
組件: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

語法

'宣告
Public Function GetSubscriptions ( _
    nsApplication As NSApplication, _
    subscriptionClassName As String _
) As SubscriptionEnumeration
public SubscriptionEnumeration GetSubscriptions (
    NSApplication nsApplication,
    string subscriptionClassName
)
public:
virtual SubscriptionEnumeration^ GetSubscriptions (
    NSApplication^ nsApplication, 
    String^ subscriptionClassName
) sealed
public final SubscriptionEnumeration GetSubscriptions (
    NSApplication nsApplication, 
    String subscriptionClassName
)
public final function GetSubscriptions (
    nsApplication : NSApplication, 
    subscriptionClassName : String
) : SubscriptionEnumeration

參數

  • nsApplication
    An NSApplication that represents the Notification Services application containing the specified subscription class.
  • subscriptionClassName
    A String containing the name of the subscription class for which all subscriptions for this subscriber should be retrieved.

傳回值

A SubscriptionEnumeration that contains all subscriptions for the subscriber for the specified Notification Services application and subscription class. To see all subscription classes for an application, use the Microsoft.SqlServer.Management.Nmo.SubscriptionClass class.

範例

The following examples show how to use the GetSubscriptions method to retrieve all subscriptions in one subscription class of one Notification Services application for a subscriber:

Dim instanceName As String =  "Tutorial" 
Dim applicationName As String =  "Weather" 
Dim subscriptionClassName As String =  "WeatherCity" 
Dim subscriptionFieldName As String =  "City" 
 
' Create the NSInstance object.
Dim testInstance As NSInstance =  New NSInstance(instanceName) 
 
' Create the Subscriber object.
Dim testSubscriber As Subscriber =  New Subscriber(testInstance) 
 
' Set the subscriber ID so that the
' correct records are retrieved. 
testSubscriber.SubscriberId = "TestUser1"
 
' Create the NSApplication object.
Dim testApplication As NSApplication = _
    New NSApplication(testInstance, applicationName)
 
' Retrieve the subscriber's subscriptions.
Dim testSubscriptionEnumeration As SubscriptionEnumeration = _
    testSubscriber.GetSubscriptions( _
    testApplication, subscriptionClassName)
 
Dim singleSub As Subscription
For Each singleSub In testSubscriptionEnumeration
    Console.WriteLine(singleSub(subscriptionFieldName).ToString())
Next
Console.ReadLine()
string instanceName = "Tutorial";
string applicationName = "Weather";
string subscriptionClassName = "WeatherCity";
string subscriptionFieldName = "City";

// 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 records are retrieved. 
testSubscriber.SubscriberId = "TestUser1";

// Create the NSApplication object.
NSApplication testApplication =
    new NSApplication(testInstance, applicationName);

// Retrieve the subscriber's subscriptions.
SubscriptionEnumeration testSubscriptionEnumeration =
    testSubscriber.GetSubscriptions
    (testApplication, subscriptionClassName);

foreach (Subscription singleSub in testSubscriptionEnumeration)
{
    Console.WriteLine(singleSub[subscriptionFieldName].ToString());
}
Console.ReadLine();

執行緒安全性

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

Subscriber Class
Subscriber Members
Microsoft.SqlServer.NotificationServices Namespace