Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

select sum from column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 15 Jan 2008 09:10 GMT
hey

.NET 2.0

My project have a DataSet. In this DataSet there is a DataTable, which has a
column I want to calculate the sum on... In sql this would be done like this
: select sum(column1) from table1... but AFAIK I cannot use sql statmetns
against a DataTable...

So I've been thinking about use DataTable.Select but think that wouldn't be
a good solution because in the Select method I need to provide som filter
expression, but I don't want to filter out any rows...

any suggestions?
Jeff - 15 Jan 2008 09:25 GMT
Okay, I've solved it... I used DataTable.Compute()

> hey
>
[quoted text clipped - 10 lines]
>
> any suggestions?
Marc Gravell - 15 Jan 2008 12:29 GMT
> .NET 2.0

It doesn't apply (because of your 2.0 statement), but for the list's
benefit: LINQ provides an alternative for this, using (simply)
theTable.Sum(x=>x.Column1);

Just for reference,

Marc
Ivica Muruzovic - 16 Jan 2008 08:09 GMT
use
DataTable.Compute("sum(column1)","")

>hey
>
[quoted text clipped - 10 lines]
>
>any suggestions?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.