DataTable error – “This row already belongs to another table”

I was attempting to add a DataRow from an existing DataTable into a new DataTable. 

                            Dim TempResultsFile As New DataSet

                           For Each Row As DataRow In TempResultsFile.Tables(0).Rows
                                   ‘Snip excess code

At the OeaaResults.Rows.Add(Row) line, I received the message “This row already belongs to another table”. Well duh, of course it belongs to another table. What’s your point?

But that kind of brilliant arguing did not solve my problem. Instead, I found which did solve my problem. In the article, Paul says to use the DataTable.Import method instead of DataTable.Add. So I changed




and the error was resolved. Joy and happiness abound.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: