vandy02
asked on
C# -- trying to add dataset row from one dataset to another -- ERROR: This row already belongs to another table.
I have a dataset with lets say ten rows. I am trying to loop through the dataset and find those that have the first column equal to 'ABC' and add those to another dataset. Refer to my code below. I receive the error 'This row already belongs to another table'. I need to create a separate dataset as I am needing to use the data somewhere else.
foreach(DataRow dr in dsAll.Tables[0].Rows)
{
if (dr[0].ToString() == "ABC")
{
dsQuery.Tables[0].NewRow() ;
dsQuery.Tables[0].Rows.Add (dr);
}
}
Thanks
foreach(DataRow dr in dsAll.Tables[0].Rows)
{
if (dr[0].ToString() == "ABC")
{
dsQuery.Tables[0].NewRow()
dsQuery.Tables[0].Rows.Add
}
}
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.