问候everyone-添加行到DataTable问题
在我的代码下面我试图从现有的数据表(dtResult)添加一行到一个新的DataTable(dtCopyResult)如果电子邮件地址不匹配。所以我猜我对ADO.NET的了解不够全面,因为每当我尝试运行我的下面的代码时,我都会得到一个“This Row already already belong to another table”。请让我知道我该如何解决这个..
非常感谢
if (checkBox1.Checked)
{
for (int i = dtResult.Rows.Count - 1; i >= 0; i--) //dtResult is a DataTable
{
foreach (object email in emails) //emails is an ArrayList of email addresses
{
if (email.ToString().ToUpper() != dtResult.Rows[i][3].ToString().ToUpper())
{
dtCopyResult.Rows.Add(dtResult.Rows[i]); //dtCopyResult is a new blank DataTable that I'm trying to add rows to
}
}
}
}
尝试使用CopyResult.Rows.Add(new dtResult.Rows [i]);只是猜测 – Gage 2010-11-16 16:54:18