Moving info between two tables

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
 
V

Val Mazur \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top