Q: sum of column

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
 
M

Marina Levit [MVP]

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

G .Net

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top