Solution to "this row already belongs to another table"

Source: Internet
Author: User

The error "this row already belongs to another table" occurs when the data in one able is copied to another datatable by condition. For example

Datatable dt = new datatable (); dt = Ds. tables ["all"]. clone (); // clone the all structure and pass it to DT datarow [] DR = This. dataset31.tables ["product"]. select ("BC = 1"); // obtain the qualified row through the condition (INT I = 0; I <dr. length; I ++) {// Add the array elements to the table... DT. rows. add (Dr [I]); // error message: This row already belongs to another table}

Solution:

You only needCodeChange

DT. Rows. Add (Dr [I]. itemarray );

That's all!

The itemarray method of rows obtains or sets all values of this row through an array.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.