Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

  • *Experts*
Posted

Look at the ImportRow method of the DataTable.

 

-ner

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...