troubleshooting Question

Getting the Sum of a database column.

Avatar of NickMalloy
NickMalloyFlag for United States of America asked on
.NET ProgrammingDatabasesC#
3 Comments1 Solution107 ViewsLast Modified:
I have a database column that I am trying to get the sum for every record. In my test sample I am only returning 6 records

My column is called WageAmount. I have tried everything and my decimal shows a value of 0. The statement returns no row with a null value.

convert(decimal(18,2),Sum(PR.WAGE_AMOUNT end)) AS [WageAmount],

In c# my code is
 decimal d = 0;
                decimal total = dt.AsEnumerable().Where(r => !r.IsNull("WageAmount") && decimal.TryParse(r["WageAmount"].ToString(), out d)).Sum(r => d);

d = 0 and total = 0. What am I doing wrong?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros