Home All Groups Group Topic Archive Search About
Author
25 Sep 2006 2:58 PM
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

Author
25 Sep 2006 3:21 PM
Marina Levit [MVP]
Look into the DataTable Compute method. If you look at the documentation,
you can find the aggregate expressions supported.

Show quoteHide quote
"G .Net" <nodamnspam@email.com> wrote in message
news:qu2dnb_78PEwbYrYnZ2dnUVZ8qKdnZ2d@pipex.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
>
Author
27 Sep 2006 8:42 AM
G .Net
Hi Marina

Many thanks!

Show quoteHide quote
"Marina Levit [MVP]" <someone@nospam.com> wrote in message
news:OWBoMZL4GHA.1252@TK2MSFTNGP04.phx.gbl...
> Look into the DataTable Compute method. If you look at the documentation,
> you can find the aggregate expressions supported.
>
> "G .Net" <nodamnspam@email.com> wrote in message
> news:qu2dnb_78PEwbYrYnZ2dnUVZ8qKdnZ2d@pipex.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
>>
>
>