QueryNotification Services Sample


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)StrataFrame Developer (7.1K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.

Attachments
QueryNotificationSample.zip (412 views, 130.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search