I have a very frustrating problem. My .net 4 app has been successfully using the SqlDependency object for some time to receive INSERT or UPDATE notifications from SQL server.

However the database it receives notifications from has just been updated (it is the back end to a 3rd party app so I don't know what the update entailed) and now when I restart my SqlDependency app it does not behave properly. During the StartSQLDependency() method this line triggers the dependency_OnChange event:

using (SqlDataAdapter adapter = new SqlDataAdapter(_SqlCommand))
    adapter.Fill(_datatable);   

With SqlNotificationEventArgs:

e.Info "Query"
e.Source "Statement"
e.Type "Subscribe"

Previously I had only seen:

e.Info "Update" or "Insert"
e.Source "Data"
e.Type "Change"

Can anyone please suggest what my have changed in the database to cause this?

有帮助吗?

解决方案

I know this is old, but for future generations...

In trying to research SqlDependency triggers, I came across a CodeProject that says that an event with those parameters indicates a bad query being used for the notifications (about halfway down the article).

Microsoft has an article about the supported notification statements (for SQL Server 2008) and how to properly build them to avoid this error event.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top