Updating a dataset using SqlDependency

G

Guest

I am trying to update a DataGrid by binding to a dataset located in another
class.
In this class, I subscribe to a Query Notification using a SqlDependency.
In the SqlDependency's OnChange event, I attempt to merge a temporary dataset
FILLed with a DataAdapter with a private dataset of the class. It performs
well enough until the OnChange event fires at an increased rate, when I see
the "DataTable internal index is corrupted: '13'" exception arise. I am
guessing my problems have to do with multiple threads attempting to change
the local dataset at the same time. I've tried using a lock statement to
lock the dataset around any operations with the dataset to no avail. Can
someone offer me an approach to this issue?

Thanks,
Chris
 
J

Jeff Dillon

From Google:

Seems like I found solution for this issue: before updating row's values
need to call DataRow.BeginEdit() and call DataRow.EndEdit() after all
changes are made.

Looks like ADO.Net modifies column values implicitly calling .BeginEdit()
and .EndEdit() BUT when there are several threads running simultaneously and
accessing DataTable ADO.Net do not synchronize those write operations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top