Solved

C# -- trying to add dataset row from one dataset to another -- ERROR: This row already belongs to another table.

Posted on 2006-06-21
1
1,096 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:vandy02
1 Comment
 
LVL 11

Accepted Solution

by:
anyoneis earned 500 total points
ID: 16957419
foreach(DataRow dr in dsAll.Tables[0].Rows)
{
if (dr[0].ToString() == "ABC")
{
    dsQuery.Tables[0].Rows.Add(dr.ItemArray)
}
}


David
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fomat Json objects 6 28
Performance  Html.BeginForm vs jQuery 3 50
Word Directory is not in the drop down list 4 25
Run time Error 4 34
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now