Moving info between two tables

  • Thread starter Thread starter Prasun
  • Start date Start date
P

Prasun

Hello:

I have 3 datatables under a dataset . They have the same columns and were
populated from the same excel sheet. I would like to move the info from one
column in a datatable to another column in another datatable. I have
already defined a relationship between these three tables. How would i go
about doing the transfer of this data. Does anyone have any sample code?

Thank You
Prasun
 
Hi,

I do not have a script code. But if your datatables have a relations, then
you could do next

Loop through the collection of the rows for the parent DataTable and call
GetChildRows method for each DataRow in this collection to get related rows
from the child DatTable. Then populate values. Here is some sort of
script(but not tested) in a case if you have one-to-one relation between the
DataTables

Dim loRow as DataRow
Dim childRows() As DataRow

For each loRow in MyParentTable.Rows
childRows=loRow.GetChildRows("MyRelationNameHere")
if (not childRows is nothing) andalso childRows.Length<>0 then
loRow.Item("MyColumnName")=childRows(0).Item("MyColumnName")
endif
Next
 
Back
Top