views:

70

answers:

2

Hi,

I have 24/7 service which keeps setup (configuration data) for charging, routing and etc in the Sql Server. Once it is started it loads the data from table using Linq2SQL and use the data through all the application. And we need a solution to update the setup data in the table without restarting the application. So I am interested is it possible to catch/determine that the table was updated so I can refresh the setup data in the application. I mean is it possible to have events which will raise when there is any delete, update or insert on the table.

Thank you.

+2  A: 

You're looking for the SqlDependency class.

SLaks
Seems this is what I need, but as I understand it is using notification services and as I know there are no notification services on MS SQL 2008. Correct me if I am wrong
Incognito
You are wrong; this is supported by SQL Server 2005 _and higher_. http://msdn.microsoft.com/en-us/library/t9x04ed2.aspx
SLaks
Since this is what I expect. Thank you. I will try it.
Incognito
A: 

SQL Server has the @@ROWCOUNT function, it will tell you how many rows were affected. Not sure how you would get to it from LINQ

I mean is it possible to have events which will raise when there is any delete, update or insert on the table.

On the database side this can be accomplished with a trigger

SQLMenace
You're misunderstanding the question. (Unless I am)
SLaks
Actually the point is not to get the affected rows, but I need somehow to know once there are any changes on my setup table. To have something like publish subscribe. I need my application to subscribe to any changes on table.
Incognito
Sorry may be I didn't clearly mentioned that I need the event to fire on application side, so triggers will not work.
Incognito