Q: sum of column

  • Thread starter Thread starter G .Net
  • Start date Start date
G

G .Net

Hi

I'm using VS2003. I have a datatable and I want to sum the values in a
column. At present I'm looping through the rows of the datatable and
incrementing a variable with the values in the column. This works. However,
I'm wondering if there is a faster way to do it?

I'm working on a dataset rather than the SQL server itself so I can't use
"SUM" i.e. I don't seem to be able to use the keyword "SUM" on a
dataset/datatable.

Can anybody help?

Thanks
 
Look into the DataTable Compute method. If you look at the documentation,
you can find the aggregate expressions supported.
 
Hi Marina

Many thanks!

Marina Levit said:
Look into the DataTable Compute method. If you look at the documentation,
you can find the aggregate expressions supported.
 
Back
Top