c# - Fill DataTable using array of NewRows -
and help! i'm trying fill datatable before pulled in report microsoft reporting services.
i thought run (depending on how many rows there in "maintable", , assign each category , flush rows.add , repeat apparently cannot row.add same name newrow. here's have far. help!:
mydataset.essrow newess = mydataset.ess.newessrow(); (int = 0; < ds.tables["maintable"].rows.count; i++) { datarow drow = ds.tables["maintable"].rows[i]; if(convert.toint32(drow.itemarray.getvalue(9).tostring()) > shiftdelta)//checks if instance longer shift { newess.station = "7"; newess.switch ="7"; newess.start = drow.itemarray.getvalue(6).tostring(); newess.stop = drow.itemarray.getvalue(7).tostring(); newess.switchis = drow.itemarray.getvalue(8).tostring(); timespan t = timespan.fromseconds(convert.toint32(drow.itemarray.getvalue(9).tostring())); newess.duration = string.format("{0:d2}h:{1:d2}m:{2:d2}s", t.hours, t.minutes, t.seconds); mydataset.ess.rows.add(newess); } }
don't try add same row several times, instead create new row add in each iteration of loop. can done moving declaration of newess
inside of loop rather outside of loop. beyond that, should move inside of if
statement aren't creating new row if aren't going add one.
Comments
Post a Comment