Thread: ASP.NET/Error: DataTable internal index is corrupted

Error: DataTable internal index is corrupted

msdn.microsoft.com/en-us/library/system.threading.mutex.aspx#Y2991





Re: Error: DataTable internal index is corrupted

connect.microsoft.com/VisualStudio/feedback/details/98279/funny-one-datatable-internal-index-is-corrupted


 





Re: Error: DataTable internal index is corrupted

social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/6693db3a-1098-44d4-8b18-6ca85f59b075/


 


Here are 4 reasons that I know how DataTable internal index is corrupted: '5' happens.

  

1)      Changing values during DataView.ListChanged event. This is not supported.

Look at the callstack and if you see DataView.OnListChanged and you are changing a DataRow/Set/Table, then index corruption will likely happen (i.e. thrown from DataRow.EndEdit)

Short description of the problem: the internal indexes getting notified of the edits out-of-order.

Workaround - use the DataTable.RowChanged event instead of the DataView.ListChanged.

 

2)      There is still an unfixed bug when merging data into an existing DataRow that starts in the Added or Deleted state and ends in the Modified row state.

DataAdapter.Fill, DataSet.Load, DataTable.Load when LoadOption.PreserveChanges.

DataSet.Merge, DataTable.Merge deleted rows.

DataSet.Merge(DataRow[]) for added rows.

Short description of the problem: The DataTable tells the DataView to “add” instead of “change”, resulting in index corruption.

 

3)      multi-threading

The DataSet/DataTable and any connected objects are not thread safe.  Make sure you lock all the appropriate objects.

 

4)      When the DataColumn.DataType is a reference type and the values are being changed instead of being treated as read only.

Example: DataColumn.DataType is byte[] and the column sorted. If the values in the byte array are changed instead of assigning a new byte array to the DataRow, the internal index doesn’t know about the change and becomes corrupt.  This is data being changed without the internal index being notified.

 

 




Re: Error: DataTable internal index is corrupted

support.microsoft.com/kb/932491


FIX: Data that is associated with a component that uses the System.Data object may become corrupted in an application that is built on the Microsoft .NET Framework 2.0