开发者

WPF live Update from database

开发者 https://www.devze.com 2023-02-11 10:12 出处:网络
I am building a multiuser WPF application (requirement is a desktop开发者_如何学Python app), database SQL Server 2008.

I am building a multiuser WPF application (requirement is a desktop开发者_如何学Python app), database SQL Server 2008.

There are two types of users.

The first type user will enter a record which would be stored in a table.

The second type user initially will be presented with a listbox with the records from the table. The requirement is that the listbox must be updated live (i.e. if a new record is entered by the first user the listbox must be updated).

Currently I have not yet implemented the Database functionality. I am currently working with ObservableCollection and simulating this scenario.

I would like to know the best approach for achieving this. Should i use a timer and keep querying the table? Is there a more efficient way? Is this even possible (should I switch to ASP.NET?) ?

I would appreciate any suggestions and tips that you may have.


Try using SqlDependency, since it can raise an event (OnChange) in your code when the results of a query would change on the server (as the result of an INSERT or UPDATE from another user or process, for example)

An example of its use on CodeProject for a simple live chat application:

http://www.codeproject.com/KB/database/chatter.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消