PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
DataRow 'saved' in a Queue (C#)
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
DataRow 'saved' in a Queue (C#)
![]() |
DataRow 'saved' in a Queue (C#) |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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. > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

