Copy dataTable contents to another datable

  • Thread starter Thread starter Steve Wasser
  • Start date Start date
S

Steve Wasser

Ok, I got no response to my last question, so let me reform it. I have a
master table with a whole dataset. Using cases, I will perform some
calculations and I want to peel off the current row I am working with and
push it to an empty table for use later. By the end of the program I want
the master table to be split into 44 different DataTables so I can isolate
the data and use it. Right now I'm trying this:

dr220 = DT220.NewRow();


foreach (DataColumn current1 in DT220.Columns)

{

foreach (DataColumn current in MyTable.Columns)

{

dr220[current1] = dr[current];

}

}




DT220.Rows.Add(dr220);



But this doesn't sync up becuase it returned an error that the data in
column 2 wasn't the same datatype in column one. I'm close, though...
 
Hi Steve,

You can't nest loops.
Either you loop thorough dt220 or mytable columns.
What's the tables structures? Are dt220 and mytable equal?
 
Back
Top