QueryNotification Services Sample

Author Message
 Posted 4/29/2008 4:27:47 PM
StrataFrame Developer

StrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame DeveloperStrataFrame Developer

Group: StrataFrame Developers
Last Login: 11/20/2019 8:57:25 AM
Posts: 6,610, Visits: 6,776
This sample shows how to receive query notifications using notification services in SQL Server 2005.  To do this, the following things are required:

  1. SQL Server 2005
  2. Notification services must be installed.  You will see this as a folder within SQL Server Management Studio (Notification Services)
  3. Broker Service must be enabled for the database.  If you are using the DDT, just check this in the Database properties.  Otherwise, you can enable this like this:

    ALTER DATABASE StrataFrameSample SET ENABLE_BROKER

    In this example, you will need to manually execute the above command to turn on the broker service for the StrataFrameSample database (not by default).
  4. Set the ReceiveQueryNotificationServices property to True on the BO

Next, you will want to handle the ServerDataChanged event.  This will be raised if there is an error qith the notification or if the query has changed.  If there was an error with the subscription, the Info property will indicate Invalid (in most cases).  If the ServerDataChanged event is not raised immediately after query is called, then it is subscribed.  You can determine this for sure by looking at the queues in SQL Server Management Studio.

Also, when creating queries, wildcards will not work and the schema names must be included in the queries.

Won't Work

SELECT * FROM Customers

Will Work

SELECT cust_LastName FROM dbo.Customers

How To Use This Sample

Simply run two instances of this sample once compiled.  Change the value of the last or first name on one of the forms.  You will then see a message box appear with the notification values and then refresh the dialog with the changes.

 QueryNotificationSample.zip (217 views, 130.40 KB)

Post #16012
Add to Twitter Add to Facebook

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.