0
votes

I'm having a moment of stupidness.

I have a Treeview control in WPF, that is displaying a list of Quotes, ie Quote#, Quote Name eg "Q#1000" "Server Quote" This treeview is bound to a collection of objects

public ObservableCollection quoteitems = new ObservableCollection();

Which are loaded from a SQL database via an SQLDataReader which populates the collection. Changes to the Quotes Collection are committed to SQL after calling a QuoteUpdate() method that writes the changes to the collection back to the database.

The problem is, what happens if a another user using the same app changes the Name of a Quote. How can I detect a change to the table, WITHOUT polling the table for updates, or using a timmer to refresh the data in the TreeView?

Am I missing something in binding controls to SQL? Is there a way to bind a control to a table and have updates handled by the control automatically? I see "two way data binding" and that seems to be what I'm after but haven't seen a way to do this with an SQL data source. Or am I having a dumb moment with how I'm thinking about the way SQL actually works!

1

1 Answers

1
votes

If you're using SQL Server (version 2005 and above), you can use Query Notifications to monitor changes. Have a look at this article to get a headstart on this.