SqlDependancy without Caching

Last post 05-14-2007 11:08 PM by Rex Lin - MSFT. 1 replies.

Sort Posts:

  • SqlDependancy without Caching

    05-08-2007, 11:27 AM
    • Member
      point Member
    • diesel7633
    • Member since 05-08-2007, 2:23 PM
    • Posts 8

    I'm having an issue where the SqlDependency.OnChange event isn't being fired when data is changed.  Every example that I find online seems to point to ASP.NET 2.0 using SqlCacheDependency rather than the SqlDependency object.  Is it possible to use SqlDependency or must asp.net utilize SqlCacheDependency.  The reason for asking is that I'm not storing anything in the cache object rather just checking if something has changed and executing some other code. 

    I've verified that the code is correct according to numerous other examples of SqlDependency and that service broker is enabled properly on SQL Server 2005.  Basically, could someone tell me whether it is possible.  I'm having a hunch that its not firing because HTTP is stateless and once the response is commited, all my server side objects are being released thus the dependency notification doesn't exist anymore. 

    Any insight would be very helpful.  Thanks!

  • Re: SqlDependancy without Caching

    05-14-2007, 11:08 PM
    Answer

     HI,diesel7633:

    Try to follow the notification from the server to the client. Validate each step, by inspecting the server state and by monitoring for trace events using the Profiler. Attach the Profiler to the server and monitor for event Broker:Conversation in the Broker category.
    - When your SqlCommand is executed, a notification subscription is created. Use select * from sys.dm_qn_subscriptions to see the pending query notification subscriptions.
    - each notification subscription creates a Service Broker dialog to deliver the notifications. The Profiler will show this as an Broker:Conversation event with subclass type BEGIN DIALOG (Note that there will also be a first BEGIN DIALOG event triggered by the SqlDependency.Start call in your Form.Load, ignore it)
    - when you update the data and the notification is fired, a Broker:Conversation trace event with subtype SEND will be fired in the Profiler.
    - if things go well, the query notification message will be delivered and this will show up in the Profiler as two Broker:Conversation events, one of subclass 'Dialog Created' and one 'Received Sequence Message'.

    If all events above show up in the Profiler, then the query notification message is succesfully delivered to the client. In this case, if the SqlDependency does not invoke the callback, the only thing I know to look for is if by any chance you are running into the issue described here:  http://support.microsoft.com/Default.aspx?kbid=913364

    If all but he last events show up, then you have message delivery problem. The query notification message is in the sys.transmission_queue table in the database. The transmission_status column should contain an error message explaining why it could not deliver the message. The appropiate action depends on this message.

    I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
Page 1 of 1 (2 items)