Data Platform Developer Center > Data Platform Development Forums > ADO.NET DataSet > DataTable internal index is corrupted ... Is exist an reason?
Ask a questionAsk a question
 

StickyDataTable internal index is corrupted ... Is exist an reason?

  • Monday, January 09, 2006 8:53 PMAndré Phillip Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello people, how are you?

    I'm in front of a strange error.

    I have a data form, that show and manage the data by a BindingSource control.

    I hava a dataGridView and individuals controls like textbox to edit them.

    It's work fine at the begin , but after some adds, removes or updates, the .Net retrives me the follow exception:

    "DataTable internal index is corrupted: '5'"


    It's very borried.... it's an ilogical error....

    Does anybody have some tip?

    Thank you.

    André B.

Answers

  • Saturday, November 01, 2008 1:16 AMMark.Ashton - MSFTMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    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.

     

All Replies

  • Friday, January 20, 2006 9:10 PMshron Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Did you ever find a solution to this problem?  I am having a similar exception and have been stumped....  The exception is being thrown while trying to use the FindBy.... (primary key) method in a typed dataset. Any suggestions are appreciated! Thanks!

    Here is the exception:

    System.InvalidOperationException: DataTable internal index is corrupted: '13'.
       at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
       at System.Data.DataTable.FindRow(DataKey key, Object[] values)
       at System.Data.DataTable.FindByPrimaryKey(Object[] values)
       at System.Data.DataRowCollection.Find(Object[] keys)
       at ESC.SV.Business.Trending.TrendingServiceDataSet.RefreshInfoDataTable.FindByNaturalKey(String NaturalKey)
       at ESC.SV.Business.Trending.TrendingDataService.GetOrCreateRefreshInfoRow(String naturalKey)
       at ESC.SV.Business.Trending.TrendingDataService.RefreshAverageData(ParameterIntervalCollection parameters)

  • Thursday, February 02, 2006 7:37 AMBeth MassiMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm also having the same problem when adding rows to a bound DataTable. I'm stumped as well.
  • Thursday, February 02, 2006 7:56 PMMeetJayBlack Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Not quite sure about the problem but you can try COMMIT the underlying DataTable before doing a Find.

    Hope this helps!!

    -Jay


    ** Mark the best replies as answers!

  • Thursday, February 02, 2006 9:24 PMBeth MassiMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I actually tracked my problem down to an EndEdit on the datarow. I'm not actually adding the row at all, I'm just setting some field values. I put a try/catch around the call to EndEdit and am eating the exception and it seems to still commit the values. Though I'm afraid that something wacky is just waiting to happen. I have a feeling it's related to databinding somehow. Hmmm.....

  • Monday, October 27, 2008 7:56 PMPhysicsGeekGuy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Beth,

     

    Did you ever resolve this problem.  My code throws this error when I call the EndEdit method. Should I also just "eat the exception?"

     

  • Saturday, November 01, 2008 1:16 AMMark.Ashton - MSFTMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    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.