Results 1 to 3 of 3

Thread: MySQL/VS 2008 - Getting updates from server

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Posts
    245

    MySQL/VS 2008 - Getting updates from server

    Hi there!
    I've been developing a client application wich gets some data from a MySQL server and populates it to a DataTable. The data is shown in a DataGridView. The DataTable needs to be updated every second, since the server data may change at any time. I've been wondering what is the best way to keep the DataTable up to date?

    The way I've been doing it for a while now, is that I refresh the enitre DataTable every second. This means that I have to clear the DataTable every second, for then to repopulate it. It works in one way, but sometimes it can be problematic especially when the data is displayed in a DataGridView. For me it doesn't look like the best/most efficient way to do it. So for you experienced MySQL/VB.NET-people out there; What is the best way to keep a DataTable "up to date"?

    Thanks!

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

    Re: MySQL/VS 2008 - Getting updates from server

    Add a LastModified column to the table if it doesn't already have one and set that to the current date and time each time a record is saved. You can then query the database for only records whose LastModified field is in the last second. Get the result of that query into a new DataTable and then use the DataTable.Merge method to merge it into the existing DataTable. This also means that you won't be able to delete any records but rather just flag them as Removed, Inactive or the like.
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2009
    Posts
    245

    Re: MySQL/VS 2008 - Getting updates from server

    Thanks! I will try something like that out

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