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

Sticky DataTable internal index is corrupted ... Is exist an reason?

Sticky

  • 2006年1月9日 20:53
     
     

    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.

すべての返信

  • 2006年1月20日 21:10
     
     

    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)

  • 2006年2月2日 7:37
     
     
    I'm also having the same problem when adding rows to a bound DataTable. I'm stumped as well.
  • 2006年2月2日 19:56
     
     

    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!

  • 2006年2月2日 21:24
     
     

    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.....

  • 2008年10月27日 19:56
     
     

    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?"

     

  • 2008年11月1日 1:16
    モデレータ
     
     回答済み

    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.