Solved

add row from one datatable to another

Posted on 2007-04-03
2
691 Views
Last Modified: 2013-12-16
I am trying to add a datarow from one table to another, but I am getting the error "This row already belongs to another table."

        For Each dr As DataRow In dsImport.Tables(0).Rows
                failDS.Tables(0).Rows.Add(dr)
        Next

How do I do this?  Do I need to make a copy?
0
Comment
Question by:jackjohnson44
2 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 18847299
Try

    failDS.Tables(0).ImportRow(dr)

Roger
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 18849815
datarow always "belongs" to a datatable, and cannot exist independently.
So once added to a table, the same row cannot be added again to another table.

You can actually use the following statement for what you want to do:

dt2.Rows.Add(dr1.ItemArray)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

805 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