Bluehunter

Hi, I have a problem with bindingsource component in framework 2.0.

I have a combobox bound to a bindingsource which is also bound to a dataset with 2 related tables and a datagridview bound to the same bindingsource. What I want to do is : When the selectedindex property of my combobox changes, the corresponding cell value must be changed in the datagridview. But although the value in bindingsource changes, datagridview does not display the new value. That value is displayed after I move the mouse over that cell and make it invalidate its region manually.

Another error I caught is the one that you can see as the subject of my post. I do not know why i have that message when I try to change the property of ((DataRowView)mybindingsource.Current)["MyProperty"] programmatically.

I will be grateful if someone can help me.




Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

Post a code example for the internal index is corrupted issue, this sounds like a bug.

Sorry I can't help you on the binding issue.






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Aleks

Hi Matt,

I have the same problem.

I have a typed dataset and sometimes, I don't know why, when I want to select some information in a DataTable and show (no Databinding) some information on my webpage I get this error.

Here is the exact exception :

StackTrace :
Source: System.Data
Methode: RBInsert
Message: DataTable internal index is corrupted: '5'.
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.InitRecords(IFilter filter)
at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] indexFields, DataViewRowState recordStates, IFilter rowFilter)
at System.Data.Select.CreateIndex()
at System.Data.Select.SelectRows()
at System.Data.DataTable.Select(String filterExpression)
at Composants_Publicite.Afficher()

It can work for many days and then I suddenly get this exception.

I can send you some code but I can't post it here due to security reason.

Thx for your help.






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

I'll check with the devs to see if they've heard of this one yet.




Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

We have a bug filed on this but we have not narrowed down a way to reproduce this yet. Could you reply to me with some information on how you manipulate this DataTable

For example are you modifying this DataTable from multiple threads concurrently
It is possible that this could corrupt it. According to the devs:

The internal index is corrupted "5" message typically gets thrown when 2 or more rows end with the same row id.

This is a problem for DataTable because the row id should always be unique.

So I theorize if 2 threads simultaneously add rows to the DataTable this could cause the corruption.






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Aleks

Yes It could be the problem.

My DataSet is stored on the Application Cache and every user can potentialy access and, sometimes, modify the content of a row.

But I had another exception telling that I cannot modify the same row at the same time. Now I modify it in order that the DataSet is now read only and I have no more exception on this DataSet.






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

iits Stefan

 

after I red this thread I'm sure it is a bug in .NET framwork 2.0. I discoverd this exception several times in different applications. but yet I was unable to reproduce it while debugging :-(

.. and it could not be a threading problem, having two thread inserting data, because I do not user different threads on that DataSet.

any news on it from MS

 






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

We're still looking for a repro. So if anyone out there has a repro please post it here.

Also if you have some code that reproduces it but not consistently post this too.

Anything that could help us figure out how to reproduce would be good, thanks for all your help thus far folks!






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

Note someone forwarded one repro to me thus far and it turns out that this one was caused by multi-threaded access to the DataTable.

So key thing for everyone to note. If you modify a DataTable on multiple threads, you can corrupt the indexes on it and this is by design. The DataTable is not designed to be thread safe for modifications for performance reasons. So to resolve this you need to use the lock statement around all modifications to DataTable.

Modifications include:

1. Adding, deleting, modifying rows in DataTable.

2. Selecting rows using Select method on DataTable (yes, this can modify the DataTable by creating a new index on it).

3. Creating DataViews over a DataTable (same as #2, this can cause a new index to be created on DataTable).

4. Modifying Sort property.

I am sure there are some others I missed. In general using the same DataTable on multiple threads is tricky business unless you restrict DataTable to100% read only operations (like enumerating rows and reading values).






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

iits Stefan

I am 100% sure, that this bug has nothing to do with multiple-thread. Our users ran into the bug several times a day. Now I implemented the following work-around:

' ------------------------------------------------------------------------------------------------

dt.Clear()

Me.Owner.DbConnector.FillDataAdapter(da, dt)

<CurrentBindingContext>.SuspendBinding()

Table.BeginLoadData()

Table.DataSet.Merge(dt, False, MissingSchemaAction.Add)

Table.EndLoadData()

<CurrentBindingContext>.ResumeBinding()

' ------------------------------------------------------------------------------------------------

I added the red-maked-code to the method where I do the .Reload of my DataSet. (The same Code is used after saving the Table.)

On the side of the user-code I do not change anything. Just using NewRow and Rows.Add. - what caused the corrupted: '5' Error before. And now the error is gone.

' ------------------------------------------------------------------------------------------------

Dim NewRow As DataRow = Me.Table.NewRow

...

Me.Table.Rows.Add(NewRow)

 

 

 






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

StephK

I am getting this same "data table internal index is corrupt '5'" error when trying to update a row using one of the table adapters I created with a data source in VS 2005. This code has been working without problems for months. The error occurs about 30% of the time. Here is an example of the code I am using:

DataRowView rv = (DataRowView)myBindinfSource.Current;

myDataSource.myTableDataRow row = (myDataSource.myTableDataRow)rv.Row;

row.ID = 12;

int updated = mtTableTableAdapter.Update(row);

myDataSource.AcceptChanges();

Does anyone at least know of any work arounds





Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

iits Stefan

I think the problem you have is not caused while Update and AcceptChanges are executing. you should add a Table.Begin/EndLoadData to you code or add Suspend/Resumebinding during .Fill

you can find 2 workarounds on the MS bug-report. the combination of both is workling in my applications.

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=ecc665a5-d71a-4e08-ac42-f3c6c5d758e0#Workarounds






Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

StephK

I have tried using the Begin/EndLoadData as well as the Suspend/ResumeBinding tricks to try to get this to work but this error keeps rearing its' ugly head...still only sometimes though. I really wish I could find more information regarding why this could be happening. I am not using threads at all.....



Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Tim Wright

I seem to be able to reproduce this fairly consistently. I'm handling the CurrentItemChanged event on the binding source and using that to detect changes to one column that need to be propogated to others. Whenever I set a value against a column using the binding source Current property to access the DataRowView I get this exception.

I've tried all the work arounds, but none seem to work. It doesn't seem to matter which event I connect to from the binding source, they all seem to throw this exception if I try to change the underlying data.





Re: .NET Framework Data Access and Storage Exception: DataTable internal index is corrupted: '5'. on ...

Matt Neerincx

Could you post a repro so I can get this to the dev who owns the bug

Thanks!