Loop thru dataset and write back

spikeypaul

New member
Joined
Apr 14, 2008
Messages
1
Programming Experience
1-3
I have a dataset with the following format:

ID# hours %
222 20
222 15
222 5
333 10
333 20
333 20

I imported that information from a CSV file, now what i have to do is go thru the dataset, analyze rows with same ID, add the hours, then calculate the % of that row (hours/totalhours), then post the % into their respective column. Then go to the next ID#. Can anyone point me in the right direction. You dont have to post any code, just ways to get this accomplish.
 
You know.. I'd make a parent table to this one, with 2 columns, one is the ID which will be unique (222 will appear once) and the other a column whose name was SUmHours and whose Expression property is set to Sum(ChildTableName.Hours)

In the child table I could then make another column named PercentOfHours and its Expression set to Hours / Parent.SumHours

More info:
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.80).aspx

Use the dataset designer to make a typed dataset, it will be so much easier
 
Back
Top