Question : Using the Sum operator within a DataView rowfilter

Is there a way to sum a column within a Dataview Rowfilter? I'm trying to use the following filter but I'm getting an error:

Dim View As DataView = New DataView(Me.CyclingJournal_DataDataSet.Tables("Events"))
View.RowFilter = "Select Sum(Distance) As SumOfDistance where Date >= '" & g_MonthBegin & "' and Date <= '" & g_MonthEnd & "' and RideType = '" & p_RideType & "'"

I get an error saying "Syntax error: Missing operand after 'Sum' operator."

Thanks for any help!

Answer : Using the Sum operator within a DataView rowfilter

Sorry, DataView.RowFilters do not support aggregrate functions

However, you can perform that calculation using the Compute method of the DataTable class (as razo has already pointed out)

The problem is that you can't do that inside the DataView control.   So, that means you should calculate the the sum separately and display it separately.

BTW:  If you're interested in reading more about how to perform SQL-style select statements on DataTables, you might wanna check out: http://home.hot.rr.com/graye/Articles/SQL_Engine.htm
Random Solutions  
 
programming4us programming4us