Home All Groups Group Topic Archive Search About

Updating a dataset using SqlDependency

Author
18 May 2006 3:13 PM
ChrisAtPhaseWare
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

Author
18 May 2006 7:30 PM
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.

Show quote
"ChrisAtPhaseWare" <ChrisAtPhaseW***@discussions.microsoft.com> wrote in
message news:23AF08A0-CFC8-4D05-8325-6D86CE839224@microsoft.com...
>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
Author
18 May 2006 8:22 PM
ChrisAtPhaseWare
Yes, I've seen that one.  How would you use them when using a DataAdapter
though?


Show quote
"Jeff Dillon" wrote:

> 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.
>
> "ChrisAtPhaseWare" <ChrisAtPhaseW***@discussions.microsoft.com> wrote in
> message news:23AF08A0-CFC8-4D05-8325-6D86CE839224@microsoft.com...
> >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
>
>
>

AddThis Social Bookmark Button