vb.net - loop to add data from a different datatable -


my datatable want call 2nd table:

first table:

 dim table new datatable   ' columns in datatable.  table.columns.add("monday", system.type.gettype("system.int32"))  table.columns.add("tuesday", system.type.gettype("system.int32"))  table.columns.add("wednesday", system.type.gettype("system.int32"))  table.columns.add("thursday", system.type.gettype("system.int32"))  table.columns.add("friday", system.type.gettype("system.int32"))  '  rows columns filled in datatable.  table.rows.add(1, 2005, 2000, 4000, 34)  table.rows.add(2, 3024, 2343, 2342, 12)  table.rows.add(3, 2320, 9890, 1278, 2) 

now 2nd table need loop:

** not finished, want add 1 table table2, in first row.**

   dim table2 new datatable       ' columns in datatable.     table2.columns.add("one", system.type.gettype("system.string"))     table2.columns.add("two", system.type.gettype("system.string"))      table2.rows.add()  *** add 1 (from monday) first table**** ??     table2.rows.add()     table2.rows.add()     table2.rows.add() 

using table2, how can link information of monday, add in 1 in table 2, need loop think call it.

in first table, want 1 in monday show in "one" in 2nd table, table2.

for alex:

 monday    tuesday    wed  10           40       9  20           50       6  30           70       4 

here how add first column value of table1 table2

for each row datarow in table.rows     table2.rows.add(row(0)) 'this add first column value of table1 first column of table2      'here's how index works:     'table.rows.add(1, 2005, 2000, 4000, 34)     'row(0) = 1     'row(1) = 2005     'row(2) = 2000     'row(3) = 4000     'row(4) = 34 next 

to add values 2 columns in table2 this:

for each row datarow in table.rows     table2.rows.add({row(0), row(1)})      'if take second example:      monday    tuesday    wed      10           40       9      20           50       6      30           70       4      'the first iteration through table1 add (10,40)     'the second iteration through table1 add (20,50)     'and on... next 

Comments