none
Getting external changes made to a dataset/table RRS feed

  • Question

  • Hey folks,

     

       I have a rather large C# application that uses a pair of DataSets (one per database server connected to) to populate a variety of DataTables and DataGridViews.

     

    To refresh the data(it is a multi-user application) I have a timer and a background thread that launches, fills the data into a new table, and compares the two tables for differences.

     

    Only if the tables are different, does the main thread get interrupted. When that happens I use the data table I filled in the background and swap the data from my 'temporary table' into the 'working table' to update the data without interrupting the user too much. The background refresh blips on the screen (with a loading message) for a split second and is about as unobtrusive as I could hope for.

     

    My manual refresh takes slightly longer(approx 2secs) and this is what I am concerned with.

     

    When pressing the manual refresh button, the entire process takes place in the main thread and takes 1-2 secs. I was wondering if I could cut that down by querying the server for only rows that differ than what I have in my DataSet.

     

    Ive read up on the GetChanges-Update-Merge cycle but I'm kind of curious, the way the documentation is written this seems largely for pushing data to the server.. Do these methods also get fresh changes made by another user or process?

     

    What it boils down to, is there a method for me to supply a DataSet or DataTable to a method and retrieve only rows from the Database that differ than what I have, without actually transferring the entire contents of the table over the wire again?

    Tuesday, June 19, 2007 5:09 PM

Answers

  • A common way of doing this is to add an update timestamp to the table, and a trigger to populate it.  In your refresh operation, you query the database for all rows whose update timestamp is greater than the latest update timestamp contained in your DataTable.
    Wednesday, June 20, 2007 2:04 AM

All replies

  • A common way of doing this is to add an update timestamp to the table, and a trigger to populate it.  In your refresh operation, you query the database for all rows whose update timestamp is greater than the latest update timestamp contained in your DataTable.
    Wednesday, June 20, 2007 2:04 AM
  • That is not a bad idea, and something Ive thought of briefly in the past. Unfortunately im hooking into an external back-end for one of my DataSets that I have read-only access to only. Also, our oracle server is an older version and does not support the update events (or whatever they are called).

     

    I guess ill just suffer with it for now Smile

    Wednesday, June 20, 2007 5:09 PM