Home Dashboard Directory Help
Search

Funny one, DataTable internal index is corrupted by Mystery


Status: 

Active


63
1
Sign in
to vote
Type: Bug
ID: 98279
Opened: 9/20/2005 8:05:15 AM
Access Restriction: Public
8
Workaround(s)
view
49
User(s) can reproduce this bug

Description

I got an error, quite a funny one.

Message: DataTable internal index is corrupted: '5'.

Source: System.Data/RBTree`1.RBInsert
StackTrace:    at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 position)
at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 position)
at System.Data.Index.RecordStateChanged(Int32 oldRecord, DataViewRowState oldOldState, DataViewRowState oldNewState, Int32 newRecord, DataViewRowState newOldState, DataViewRowState newNewState)
at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.SetNewRecord(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean fireEvent)
at System.Data.DataRow.EndEdit()
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at AdonisTech.Adonis2006.HelperLibrary.TableHelper.SetRowValue(DataRow row, DataColumn column, Object value) in C:\ADONIS 2006\Application\HelperLibrary\TableHelper.vb:line 33
at AdonisTech.Adonis2006.WinUI.frmEditStayPackages.UpdatePackageData(tblStayPackagesRow row) in C:\ADONIS 2006\Application\WinUI\Stay\frmEditStayPackages.vb:line 127
at AdonisTech.Adonis2006.WinUI.frmEditStayPackages.UpdateData() in C:\ADONIS 2006\Application\WinUI\Stay\frmEditStayPackages.vb:line 115
at AdonisTech.Adonis2006.WinUI.frmEditStayPackages.SaveData() in C:\ADONIS 2006\Application\WinUI\Stay\frmEditStayPackages.vb:line 42
at AdonisTech.Adonis2006.WinUI.frmEditStayPackages.btnOK_Click(Object sender, EventArgs e) in C:\ADONIS 2006\Application\WinUI\Stay\frmEditStayPackages.vb:line 34
at System.Windows.Forms.Control.OnClick(EventArgs e)
Details
Sign in to post a comment.
Posted by Daniel Smith on 3/19/2010 at 4:34 AM
Is this being investigated? Seems like a lot of people are able to reproduce this. Any chance of some sort of official comment, or resolution?
Sign in to post a workaround.
Posted by Cam.H on 3/17/2008 at 7:19 AM
I had to do as per Hadi Eskandari's submission but for EVERY new row I added, not just on an empty datatable.
Posted by Farhad Jalali on 3/19/2007 at 9:18 AM
setting:
MyDataset.EnforceConstraints=False

fixed my problem
Posted by repattern on 10/1/2006 at 8:32 PM
I got this exception thrown at me while trying to update a DataSet column bound to a ComboBox. I solved it by swapping all my ComboBoxes with Infragistics UltraComboBoxes.
Posted by Hadi Eskandari on 9/27/2006 at 12:19 AM
If you get this exception when trying to add a new record to an empty datatable, which has other views binded to data-aware controls, try adding and deleting a dummy row, before adding your main row like this:

MyDataSet.MyTableRow dummy = MyDataSet.MyTable.NewMyTableRow();
myDataSet.MyTable.AddMyTableRow(row);
dummy.Delete();

//Proceeed here
Posted by Mystery on 5/5/2006 at 9:56 AM
This error might appear in a web application when caching DataTable objects and creating DataViews on the DataTables, under stress.

A simple workaround is to use DataTable.Copy() to give every user a private copy in memory and create the DataView on the copy. Of course, performance will go down dramatically.

original code:

DataTable dt = (DataTable)Cache["key"];
if (dt != null)
{
        DataView dv = new DataView(dt);
}

new code:

DataTable dt = (DataTable)Cache["key"];
if (dt != null)
{
        DataTable dtCopy = dt.Copy();

        DataView dv = new DataView(dtCopy);
}
Posted by Mystery on 4/28/2006 at 1:49 AM
This problem has been encountered when multiple views of the same table have been created, each of which was linked to a data aware control. The workaround for this is to use the BeginInit and EndInit methods of each view.

dvView1.BeginInit();
dvView2.BeginInit();
// makes changes to table here
dvView1.EndInit();
dvView2.EndInit();
Posted by Mystery on 1/12/2006 at 7:25 AM
If the dataset happens to be on the client side and a lot of binding-sources are bound to it, merging and adding might produce the given exception. We were able to work around this by temporarily suspending the binding via BindingSource.SuspendBinding() during Merge.

// Controls are bound to BindingSource which is bound to the DataSet

BindingSource.SuspendBinding();
DataSet.Merge( changes, false, MssingSchemaAction.Add ); // this formerly corrupted the dataset - exception was thrown on any subsequent NewRow()
BindingSource.ResumeBinding()
BindingSource.ResetBinding( false )
Posted by Mystery on 10/13/2005 at 3:44 AM
Before adding the new row call BeginLoadData, after the row has been added call EndLoadData.

This works for adding new rows, not confirmed for updating existing rows.

myDataSet.MyTable.BeginLoadData();
myDataSet.MyTable.AddMyTableRow(newMyTableRow);
myDataSet.MyTable.EndLoadData();