• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 663
  • Last Modified:

Sum of Dataset column

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
Vartana
Asked:
Vartana
  • 3
1 Solution
 
iboutchkineCommented:
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
 
VartanaAuthor Commented:
I dont want to filter anything

How can i do it without filtering
0
 
iboutchkineCommented:
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
 
iboutchkineCommented:
also you can use Nothing for filter
objSum = myTable.Compute("Sum(Qty)", Nothing)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now