This is not the correct way. What you are doing in this method is to create a new Row instance and populate its values, instead of inserting the existing DataRow instance from the child table. Your code will become unmanageable if the no. of columns increases.
IMO, the correct way to do this would probably be to use the DataTable.ImportRow() method (and then the DataRowCollection.InsertAt () method). I'm just relying on memory here, so I may be mistaken about the exact implementation. On Aug 27, 2:24 am, Ana <[email protected]> wrote: > 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 >
