Never mind. I added the values for each column and now it works.

For Each row In childrenTable.Rows
                    Dim newRow As DataRow = dTable.NewRow
                    newRow("Id") = row("Id")
                    newRow("Name") = row("Name")
                    dTable.Rows.InsertAt(newRow, indexInsert)
                    indexInsert = indexInsert + 1
                Next

On Aug 26, 3:15 pm, Ana <[email protected]> wrote:
> Hi,
>
> I have two DataTables (dTable and childrenTable) and I need to insert
> one row from childrenTable to dTable in a specific position. My code
> is like this:
>
> For Each row In childrenTable.Rows
>      Dim newRow As DataRow = row
>      dTable.Rows.InsertAt(newRow, indexInsert)
>      indexInsert = indexInsert + 1
> Next
>
> However, I'm having the error: "This row already belongs to another
> table". Any ideas about how to solve this problem?
>
> Thanks in advance,
>
> Ana

Reply via email to