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.
Saya Software Engineer di BukaLapak.
Simak pemikian saya soal dunia Software Engineering via Twitter di @agungsetiawanmu dan facebook
Blog ini saya update seminggu sekali jadi sering-sering saja mampir
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 *