DataRow 'saved' in a Queue (C#)

  • Thread starter Thread starter Bishman
  • Start date Start date
B

Bishman

Hi,

I am using a Queue object to save the contents of a DataSet within a
'foreach' loop.

I use the .Enqueue method to add the Row to the Queue, but when the .Delete
method is called on the original row each 'field' value has the exception
'dr.ItemArray' threw an exception of type
'System.Data.DeletedRowInaccessibleException'

The code:

casc_WALLBOARDTableAdapter.Fill(insightDataSet.CASC_WALLBOARD);

foreach (InsightDataSet.CASC_WALLBOARDRow TriggerRow in
insightDataSet.CASC_WALLBOARD)
{
DataRow dr = TriggerRow;
lock (POLICY_QUEUE)
{
POLICY_QUEUE.Enqueue(dr);
}
TriggerRow.Delete();
}
casc_WALLBOARDTableAdapter.Update(insightDataSet);

Why does the dr allways refer back to the original datarow and not the copy
I have placed in the Queue. How can I overcome this, ie save a copy of a row
to a queue ?? Is it because Datarows are only reference types ?

Any help appreciated.

Thanks

Jon.
 
OK - I have sorted it

I have used the .ItemArray property of the Row to save the fields to an
Object [] array.

This seems to be the way to do it.

Thanks Anyway.

Jon.
 
Back
Top