PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET DataRow 'saved' in a Queue (C#)

Reply

DataRow 'saved' in a Queue (C#)

 
Thread Tools Rate Thread
Old 15-09-2006, 03:16 PM   #1
Bishman
Guest
 
Posts: n/a
Default DataRow 'saved' in a Queue (C#)


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.


  Reply With Quote
Old 15-09-2006, 04:15 PM   #2
Bishman
Guest
 
Posts: n/a
Default Re: DataRow 'saved' in a Queue (C#)

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.


"Bishman" <jonathan.bishop@btinternet.com> wrote in message
news:%23NUNWHN2GHA.1292@TK2MSFTNGP03.phx.gbl...
> 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.
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off