Can't get Service Broker to communicate with my C# app

  • The weirdest problem has been melting my brain today... many hours have been spent trying to resolve this. 🙁

    Just so you know where I am coming from, I am fairly good with SQL Server - I have used it for a several years and have done basic administration.

    I have implemented a C# program that requires notification when a table in SQL Server changes.

    To do this I created an SqlDependancy object and attached it to my SqlCommand object, which is then run against the DB. The SqlDependency.OnChange event is wired up in my code.

    Expected behaviour is that my code OnChange event will fire when the db table changes.

    Actual behaviour is that the event in code is only fired when I restart the SQL Server instance?!?!

    To simplify this, I used the sa user in my connection string (so no permission problems). Also my SELECT statement used in the SqlCommand object is a simple "SELECT ".

    Has anyone seen this before? I have tried looking up Service Broker in SQL Server Books but it's like trying to read up on nuclear physics... all the info is very deep and complex, and I really have no idea where to start.

    Any help, any ideas are most appreciated. 🙂

    Apologies, but this is cross-posted in the main discussion forum in case I have posted this in the wrong place (it didn't seem like CLR but it involves .NET code).

  • Take a look here and see if helps.

  • Amazing! I really wasn't holding out much hope as the symptoms they had were somewhat different to mine, but the following line did it:

    ALTER AUTHORIZATION ON DATABASE::[dbname] TO [sa];

    Many thanks for the link, I looked and looked yesterday and couldn't find anything so I really appreciate the help. 🙂

  • Glad you found your answer.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply