I have a System.Data.DataSet and 1 single table in it. The table has many columns.
In a certain event handler, I am setting a decimal value for one of the fields, in a data row which is already existing (at the time of setting).
In a very rare case, I am getting a ArgumentOutOfRangeException
exception.
Message: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Call Stack:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Data.RecordManager.NewRecordBase()
at System.Data.DataTable.NewRecord(Int32 sourceRecord)
at System.Data.DataRow.BeginEditInternal()
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at CPITS.Data.OrdersRow.set_ExecutionPrice(Decimal value)
Strange thing is, this is happening from the code which the framework has generated (Of course, I didn't write the Setter for the DataColumn).
Can you please help me understand & fix this problem?
EDIT
Below is the code where I am setting value:
void ibclient_OrderStatus(object sender, OrderStatusEventArgs e)
{
Data.OrdersRow drOrders = data.Orders.FindByOrderId(e.OrderId);
if (drOrders != null)
{
drOrders.FilledQuantity = e.Filled;
drOrders.ExecutionPrice = e.AverageFillPrice; //Sporadic Exception when setting a decimal value
}
}