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