1

with the following code, my OnChange event is not raised:

SqlDependency.Start(connectionString);

SqlConnection conn = new SqlConnection(connectionString);
   conn.Open();

                using (SqlCommand command = new SqlCommand(
                    "SELECT Name, Description FROM dbo.Boms",
                    conn))
                {

                    SqlDependency dep = new SqlDependency(command);
                    dep.OnChange += dep_OnChange;

                    // Execute the command.
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        // Process the DataReader.
                    }
                }

I googled for any possible constrains to the query, but my query seems to be ok. The dep object is also properly created, but I tried to insert (successfully) a record inside my Boms table but I received no feedback or event. Inside Sql Server 2012 I see a new queue everytime I launch my application.

I looked for errors into system table but all seems ok.

Any hint to understand at least where is the problem?

Thanks!

2
  • Does executing process have select permission? Commented May 28, 2014 at 8:43
  • @LIUFA: I didn't write that I also use this method that returns me true: private bool CanRequestNotifications() { SqlClientPermission permission = new SqlClientPermission( PermissionState.Unrestricted); try { permission.Demand(); return true; } catch (System.Exception) { return false; } } Commented May 28, 2014 at 9:49

1 Answer 1

1

Read The Mysterious Notification, Troubleshooting Query Notifications Troubleshooting Dialogs and Using SQL Trace to Troubleshoot Query Notifications for troubleshooting tips.

Run this to ensure the executes as sandbox context does not run into orphaned dbo sid issues:

ALTER AUTHORIZATION ON database::[<yourdbname>] TO [sa];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.