0

I have implemented SQlDependency to detect changes in database tables.

I have inserted multiple records (approximately 500 records) in a database table using a while loop. But SQL Dependency is not detecting every change. The Change event method (of SQL Dependency) should execute 500 times when I insert 500 records but is firing less. Issue might be due to data changes occurred in table very quickly. If I add delay in while loop, it is working fine.

I want a solution to detect all the changes of DB table when large data changes occurred in database in short time. I have used SQL Dependency to detect DB changes. Please also let me know if I can use alternate of SQL Dependency.

Abe
  • 485
  • 5
  • 17
  • It is possible that it was optimized and calls were merged into single transaction? – Karolis Kajenas Jun 07 '17 at 05:34
  • Data will be added/updated dynamically from applications. I want to track on DB table and based on I have to do broadcasting using signalR and again need to update that records. Can you let me know how can I optimize and merge into single transaction? – Dharmesh Parekh Jun 07 '17 at 05:38
  • 1
    The intended use of `SqlDependency` is to detect that something has changed, for applications to invalidate their caches. It is explicitly not designed (and will not perform correctly) if you intend to get a notification for every individual change. If you must detect all individual changes, use a trigger. – Jeroen Mostert Jun 07 '17 at 08:38
  • I want every individual DB notification (change) in my WPF application but not at database level. That's why I used SQL dependency. But it is not working correctly. Please let me know if you have any other way to achieve this. – Dharmesh Parekh Jun 07 '17 at 09:04

0 Answers0