tags:

views:

35

answers:

2

Hi folks,

Good Day!

I have a datagridview using datatable as my datasource. Now my problem is how do I keep my datatable sync to our Server database? Like for example somebody tried to update the database so automatically my datatable will be update too. Without using iteration. Is this possible guys?

Thanks a lot.

Regards, kurt

A: 

Is this using WPF or Winforms?

simple way: each client regularly polls the server and updates as needed.

More complex way: service oriented using callbacks, eg http://www.switchonthecode.com/tutorials/wcf-tutorial-events-and-callbacks

SteveCav
@steve, thank you sir, i'm using winforms.
kurt_jackson19
A: 

There is nothing automatic in software. We need to automate things that seems to be automatic. You can use caching mechanism for your solution. The datatable can be filled using a cache. The cache can be made invalid on change of underlying tables in the database. And upon invalidating, the datatable shall have to be recreated again and so the gridview shall have to be updated.

If you are using ASP.NET, you can refer the MSDN article on the same here: http://msdn.microsoft.com/en-us/library/ms972379.aspx

Kangkan
@Kangkan - i'm using winforms sir. thanks.
kurt_jackson19
If you wish to use the approach of cache, you shall have to implement it. You can refer to caching techniques discussed here:1. http://www.codeproject.com/KB/cs/cacheinwinformapps.aspx2. http://weblogs.asp.net/rosherove/archive/2003/08/12/23813.aspxThe first one is from Codeproject that implements a cache. The next one is actually using ASP.NET cache in winform as shown by Roy Osherove.
Kangkan