I have a vb.net program that runs a stored procedure on a database. After I build the dataset, i'm scanning the table inside the dataset searching for specific information. I used Select Case statements to find the correct info. The problem i'm running into is I can't figure out how to display my results as a "sum". I know that it's because i'm using "For Each" but i'm unsure how to assign "Result" to ds.tables(0).Rows
Code:
For Each Result As DataRow In ds.Tables(0).Rows
Select Case Result("Report")
Case "TOTALS"
Select Case Result("Description")
Case "Coupons", "Coupons Tax-Free", "GC"
MsgBox(Result("netAmt"))
End Select
End Select
Next
As coded i'm receiving 3 message boxes. The first one:
"15"
The Second One:
"10"
The Third:
"5"
I'd prefer to see the sum of all 3 found:
"30"
How can I retrieve the sum of these, keeping in mind it's possible that one of the 3 comes back as 0 in some cases
ds.Tables(0)coming from? If it's a database, it's best to let the DB engine do the aggregation.