Tanx jmcilhinney for your advice. And tanx Herman for your suggestion.
I study the code again through all night, tested all possible solution and got it solved.
Finally, i used LINQ to perform the group and summation and it works. Tanx all for your support :)
sir, can you please show me the example on how to loop through the rows and add the data to a Dictionary?
What am i confused is, in the first step in post #2 which is to loop through the rows and add the data to a Dictionary , i should declare the type of DURATION as what? if you refer to #7...
I know how to do the conversion from string to timespan type and sum it in vb.
The problem is, i got the total of summation for the whole of DURATION column. Not sum by group (LINE).
Do you have any idea how i can sum it by group?
ok. So first i dont have to convert the DURATION of type Char to timespan?
I just insert straight from database to the dataset without converting it?
Is that so?
Sir, can you please show example please...
Now i'm trying to do the Dictionary method and get error "an item with the same key has already been added"
Here is the code:
Dim dct As New Dictionary (Of String, String)
For each r As Datarow In Ds.Tables(0).Rows
jmcilhinney, tanx for your reply.
However, I'm not familiar with DICTIONARY and have tried doing the summation using LINQ (just learn about LINQ yesterday).
So far here is what i've done:
Dim totalSum As Datatable = Ds.Table(0)
Dim query = _
From s In totalSum.AsEnumerable() _
Let line =...
Hi, i'm a newbie and get stuck with this problem for a few days.
I have datatable with two column, line and duration.
I want to sum the duration based on the line group. For example: