Solving “This Row Already Belongs to Another Table” Error

Yesterday i helped my friend that had following error when she tried to copy rows form DataTable to another DataTable, “This row already belongs to another table”.


Below is snippet of the code

Although logically the code was right, unfortunately it threw “This row already belongs to another table”.

If you are facing the same error than here’s the solution.
1. Make sure the destination DataTable has the same column with original DataTable by using Clone() method.
2. Use ImportRow() instead of Add()

Hope it helps others 😉

Facebook Comments

Agung Setiawan

Agung Setiawan adalah software engineer di, penulis sekaligus pecinta sastra, dan pembaca buku

Halo, perkenalkan saya Agung Setiawan.
Seorang Software Engineer di BukaLapak, penulis buku, blogger, gunpla builder, tech educator.
Simak pemikiran saya soal dunia Software Engineering via Twitter di @agungsetiawanmu dan facebook
Mau belajar Vim bareng saya?
Belajar ngoding dari nol menggunakan PHP

Leave a Reply

Your email address will not be published. Required fields are marked *