Results 1 to 2 of 2

Thread: How to refresh data when data changes in database?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    How to refresh data when data changes in database?

    I have a WinForms app that connects to SQLite to get data. I populate that data in various controls. I have a method which updates the data in the database at certain intervals. If data in the database changes that happens to be visible on the screen, like in a list box or treeview, how can I update that data? Are there any frameworks available to assist with this?

    Visual Studio 2010

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: How to refresh data when data changes in database?

    Are you saying that the same instance of the application is doing the updating or you want one instance to know about changes made by another instance?

    If it's the former then your app already knows that there are changes so it already knows to go to the database and get them. In fact, it may be the case that you don't even need to get anything because you perhaps should be making the changes in the application first. I've seen many people save changes to a database and then expect to update a grid when what they should be doing is updating the grid first and then saving from there.

    If it's the latter then I think you're out of luck with SQLite. SQL Server can provide notifications but, even then, the burden is significant so it needs to be for just a small number of clients. In that case, your best bet is probably to use timestamps on your database records and then have your application poll the database for records with a timestamp later than the last time it checked.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width