I have a Database with some tables,
I wanna to run a method in C# whenever some data is written in the tables.
I know I have to use triggers, but I don’t know how!!!
It would be appreciated if you guide me.
P.S:
I’m using SQLExpress 2008
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ADO.NET provides very useful class called SqlDependency. You can subsribe to an
OnChangeevent when specified table in database changes.Here is documentation and example:
http://msdn.microsoft.com/en-us/library/62xk7953.aspx
It looks very nice and works!
However, you will have to enable Service Broker in your database in order to receive these notification. Here is how to do that: