Jrud
Jrud

Reputation: 1004

.NET Event handler on a database object

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:

Upvotes: 1

Views: 2005

Answers (1)

Chris Shain
Chris Shain

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

Related Questions