microsoft.public.sqlserver.notificationsvcs
[Top] [All Lists]

Re: How to verify if subscriber exists?

Subject: Re: How to verify if subscriber exists?
From: "TonyS"
Date: Fri, 8 Dec 2006 23:51:40 -0000
Newsgroups: microsoft.public.sqlserver.notificationsvcs
What's does 'right way' mean?
'Right way' is subjective and changes with time.

Similarly 'Bad practice', in the absence of something else found within a 
reasonable time searching, is meaningless I think.

Tony S.

"Aleksey" <[email protected]> wrote in message 
news:[email protected]
> The question was: how to do this without getting OutOfRange or any other
> Exception. This is a VERY BAD practice. One should never through 
> exceptions
> casually - they consume resources and slow down execution. Thanks for your
> advice, but there must be a right way to verify if a subscriber exists.
>
> Aleksey
>
>
> "TonyS" wrote:
>
>> I thought I had posted this snippet that helps with your query
>>
>> Tony S.
>> Public Function IsExistingSubscriber(ByVal subscriberId As String) As
>> Boolean
>>
>> Dim Instance As New NSInstance(Me.sdm_InstName)
>>
>> Dim Application As New NSApplication(Instance, Me.sdm_AppName)
>>
>> If Not instance Is Nothing Then
>>
>> Dim subscriber As Subscriber
>>
>> Dim subscriberEnumeration As SubscriberEnumeration
>>
>> subscriberEnumeration = New SubscriberEnumeration(instance)
>>
>> Try
>>
>> subscriber = subscriberEnumeration(subscriberId)
>>
>> Return True
>>
>> Catch ex As IndexOutOfRangeException
>>
>> IsExistingSubscriber = False
>>
>> Catch ex As Exception
>>
>> IsExistingSubscriber = False
>>
>> End Try
>>
>> Else
>>
>> Return False
>>
>> End If
>>
>> End Function
>>
>>
>>
>> "Aleksey" <[email protected]> wrote in message
>> news:[email protected]
>> > What is the right way to check if a subscriber exists already?
>> > Subscriber.Add() raises an error if the ID is already there, and
>> > SubscriberEnumeration raises an error if it is not there.
>> > How can I do that without errors? I cannot find a method or property 
>> > for
>> > that...
>> >
>>
>>
>> 



<Prev in Thread] Current Thread [Next in Thread>