Groups | Blog | Home
all groups > sql server notification services > july 2005 >

sql server notification services : Subscriber.Enabled() returning incorrect result


Pinal P via SQLMonster.com
7/26/2005 1:32:48 PM

I am giving my users the ability to disable their account from my NS front-
end web app and to do that I am using the NS API.

In order to disable the subscriber account, I
- instantiate a Subscriber object for the subscriber
- set its Enabled property to False
- call the Update() method

The problem is, when I create another Subscriber instance for the same
subscriber somewhere else and check the subscriber.Enabled() property, it
always returns True (even if I restart the app), whereas the database is
showing that the subscriber account is disabled. Any idea why this is
happening???


--
Message posted via SQLMonster.com
Joe Webb
7/26/2005 3:05:12 PM
Hi Pinal -

This code snippet demonstrates how to use the SubscriberEnumeration
object to retrieve a subscriber object and view its Enabled property
in a Label.

private void button1_Click(object sender, System.EventArgs e)
{
//the subscriber id we will work with
string subId = "joew@webbtechsolutions.com";

//Create an NSInstance object
string instanceName = "myNotifyInstance";
NSInstance instance;
instance = new NSInstance(instanceName);

//create disable an existing subscriber
Subscriber subscriber =new Subscriber(instance);
subscriber.SubscriberId = subId;
subscriber.Enabled = false;
subscriber.Update();

//create a new subscriber object
Subscriber subscriber2 = new Subscriber(instance);

//set the subscriberId
subscriber2.SubscriberId = subId;

//Create a SubscriberEnumeration object
SubscriberEnumeration subscribers = new
SubscriberEnumeration(instance);

//retrieve the subscriber object
subscriber2 = subscribers[subId];

//check the enabled property
label1.Text = subscriber2.Enabled.ToString();


}

HTH....

--
Joe Webb
SQL Server MVP


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)


On Tue, 26 Jul 2005 13:32:48 GMT, "Pinal P via SQLMonster.com"
[quoted text, click to view]
AddThis Social Bookmark Button