angus234 Posted November 3, 2004 Posted November 3, 2004 Hi all, Assume that both DataTable are the same schema, I want to copy a row from one DataTable to another DataTable by m_dtItem.Rows.Add(m_dtOrgItem.Rows(0)) However, it said that Exception Details: System.ArgumentException: This row already belongs to another table. So, How can copy a row from one DataTable to another DataTable? Thank you. Quote
kejpa Posted November 3, 2004 Posted November 3, 2004 Hi, Haven't tried it (and I know giving non-tested tips is a death penalty crime...) but what if you create a new row, put the row to be copied into that row and then add it to the destination table? dim NewRow as DataRow=m_dtItem.NewRow NewRow=m_dtOrgItem.Rows(0) m_dtItem.Rows.Add(NewRow) HTH Kejpa Quote
*Experts* Nerseus Posted November 3, 2004 *Experts* Posted November 3, 2004 Look at the ImportRow method of the DataTable. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.