Let's say you have a form with a component that displays data from a view on an SQL server. The component would be something like a ListView or DataGrid - basically something that can display the data in a 2D grid format. Another application changes the data that the SQL view describes, and does this regularly but at undefined intervals.
The problem is this: the form needs to keep itself updated with the most current data, with the minimum of latency between it changing and it displaying.
The platform constraints are that you must use .NET 2.0 and Microsoft's SQL Server. Assuming that you have full control of all other parts of this system and can design it any way you want - what's the best way to do this?
The ones I've thought of so far:
Regularly polling for the data and comparing to see what's changed. Either by:
- reading the entire view from the SQL Server and comparing it against the currently displayed data, row by row, updating the displayed data as it goes, or
- somehow recording a table of changes to the view (using triggers or application logic), reading new items in there each time, and applying this to the displayed data.
Adding a layer in between the SQL Server and both the form and the updating application, so any updates from the main application go here and the form application can be notified of changes in real time. Not really sure how this would be done in practice though.
Putting triggers on the tables that somehow cause the form to be notified - calling some custom extended stored procedures maybe?
Anyone who has done this before, please offer your insights!
Also please comment if you know of any existing libraries that do all this already.