Empty rows appearing in typed dataset

I have a problem with a typed dataset which is updated using a background worker. The app works roughly like this:

1. Some parts of the UI are bound to a typed dataset which has several values that can not be null.

2. A background thread commits changes and fetches new data from the server on a regular basis through a web service, and stores it into a temporary dataset.

3. The commited data still marked as modified / added etc. is accepted by calling dataset.AcceptChanges(). Immediately after that the fresh data in the temp ds is merged into the actual dataset. This is done on the UI thread to avoid multithreading issues..

Now, here's the problem. Every now and then a completely empty row appear in the main dataset which results in all kinds of exceptions when code tries to access the row. This can happen when the app is not being used, so I'm fairly certain that it has to do with the accept / merge stuff. But I cannot figure out why and exactly when.

Any ideas what could cause this kind of behavior Thanks!



Answer this question

Empty rows appearing in typed dataset

  • ST2B

    Netterdotter,

    It looks like you are having threading issues.

    Can you try putting lock{ } around your UI dataset merge operations

    And if that doesnt help post some additional code



  • c4210

    BTW, Could calling dataset.WriteXml(...) from a background thread cause this problem
  • Richard Hathaway

    Another thing you could do is dump both the merging dataset and existing dataset to XML prior to doing the merge (using WriteXML) then dump resulting merged dataset after the merge. This would give you a log of activity you could use to track down the location of the problem.

  • Empty rows appearing in typed dataset