Reputation: 1004
I want to reduce polling in my application solution (many apps, 1 database, some 3rd party), customer wants an up-to-the-second GUI status of whats going on. Is it possible to add an event handler through .NET code to a table or database using SQL Server technologies?
Here are some solutions I've come across:
FileSystemWatcher
object pick up the file change event and trigger it that way, but that smells bad somehow.Upvotes: 1
Views: 2005
Reputation: 51339
You may want to look at SqlDependency. The only caveat is that, as the docs state,
SqlDependency was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have SqlDependency objects set up for a single database server. If you are developing an application where you need reliable sub-second notifications when data changes, review the sections Planning an Efficient Query Notifications Strategy and Alternatives to Query Notifications in the Planning for Notifications topic in SQL Server Books Online.
In general though I find the above statement to be true for most SQL Server client applications, so hopefully this shouldn't be a problem.
Upvotes: 3