Is it possible to trigger an action in Windows Service, or is it possible to raise an event that can be caught in a Service from a stored procedure.
If you imagine a service runs every 5 minutes thats performs some action. What if something happens in a database or a stored procedure is executed and I want to trigger this action earlier than the 5 minutes.
Does anybody have any ideas?
Thanks
Ed
Following on from Mehrdad’s comments, I was able to solve the problem using the SqlDependancy Class in the .NET framework.
This Class allows you to register a SQL query and connection with it, when the result of that query changes an event is raised to indicate a change in the data.
This allowed me to catch data changes almost instantaneously and deal with appropriately.
In order to use this Class you will need to Enable Query Notifications on the database you wish to query see: Enabling Query Notifications
A good example of how to use this class in a Windows Application is found here.