Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sum of Dataset column

Posted on 2004-09-30
4
Medium Priority
?
662 Views
Last Modified: 2008-03-03
I have a data set called MyDataSet
Then i have a datatable called MyDataTable

I want to get the sum of column 3

How would I do this ?


Thank You
0
Comment
Question by:Vartana
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 2000 total points
ID: 12192866
Private Sub ComputeBySalesSalesID(ByVal myDataSet As DataSet)
    ' Presumes a DataTable named "Orders" that has a column named "Total."
    Dim myTable As DataTable
    myTable = myDataSet.Tables("Orders")
    ' Declare an object variable.
    Dim objSum As Object
    objSum = myTable.Compute("Sum(Total)", "EmpID = 5")
 End Sub
0
 
LVL 1

Author Comment

by:Vartana
ID: 12192943
I dont want to filter anything

How can i do it without filtering
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12193149
put criteria for filter that will match all the records.
FOr example you want to calculate quantity
objSum = myTable.Compute("Sum(Qty)", "Qty>0")
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 12193224
also you can use Nothing for filter
objSum = myTable.Compute("Sum(Qty)", Nothing)
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question