470,870 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

is that safe to say a Detached DataRow neve in a DataTable's Rows collectoin? Error due to multiple threading?

Hi,

Is that safe to say a Detached DataRow neve in a DataTable's Rows
collectoin?

But in my log file, I do see a Detached row:

foreach(DataRow dr in this.currentQuotaUserDt.Rows)
{

object temp = dr[quotaId.ToString()];
.....
}

throws exception : This row has been removed from a table and does not have
any data. BeginEdit() will allow creation of new data in this row.

So maybe this exception is caused by multiple threading, the statement I
made is still right?

Thanks a lot!
Ryan
Jul 30 '06 #1
1 2289
Ryan,
Sahil Malik cleared this up very nicely in a blog post:

"When you call NewRow on a table - only the rowstate is detached. There is
private variable inside of DataRow called as _Table, which is populated by
the table instance that NewRow was called upon.

How it got the instance was - datatable stores an instance of an internal
class called DataRowBuilder, and DataRowBuilder.Table = this (the table
itself). DataRowBuilder - is what is used to generate the new row for you.

Soon as you did an Add to the rows collection, the rowstate was changed from
Detached to <<non-detached>something else, in which case the dataadapter
will now pick it."

Hope that helps out.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Ryan Liu" wrote:
Hi,

Is that safe to say a Detached DataRow neve in a DataTable's Rows
collectoin?

But in my log file, I do see a Detached row:

foreach(DataRow dr in this.currentQuotaUserDt.Rows)
{

object temp = dr[quotaId.ToString()];
.....
}

throws exception : This row has been removed from a table and does not have
any data. BeginEdit() will allow creation of new data in this row.

So maybe this exception is caused by multiple threading, the statement I
made is still right?

Thanks a lot!
Ryan
Jul 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by dudi | last post: by
5 posts views Thread by jurson | last post: by
11 posts views Thread by Tim Frawley | last post: by
reply views Thread by Dave Coate | last post: by
5 posts views Thread by samoore33 | last post: by
5 posts views Thread by Rainer Queck | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.