C# / SQL Listener to tell me if a row has been inserted into a table

前端 未结 7 1137
傲寒
傲寒 2020-12-15 10:44

Can someone post sample code or tell me how to set up a listener to notify me (trigger an event) if a new row is inserted into a SQL Server database?

I don\'t want

7条回答
  •  渐次进展
    2020-12-15 11:33

    Are you perhaps looking for the SqlDependency class, that lets your code register to be notified when changes occur?

    SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.

    Or does this fall within the realm of things that you're disallowing, it's not entirely clear?

提交回复
热议问题