|
-
March 14th, 2005, 06:01 PM
#1
Using aggregate function in Datatable select Method
I'm searching for a way to place an aggregate function in the filter expression of the datatable's select method.
I thought the syntax would be something like
dim strexp as string
strexp = "MAX(columnName)"
foundrows as datarow()
foundrows = ds.tablename.select(strexp)
The error message indicates the filter expression 'MAX(columnName)' cannot be evaluated to a boolean expression.
Are aggregate expressions supported in the the select method? I searched the online docs without success.
-
March 15th, 2005, 08:31 AM
#2
Re: Using aggregate function in Datatable select Method
try
strexp = "Columname = Max(ColumnName)"
Nicolas Bohemier
-
June 16th, 2008, 04:21 AM
#3
Re: Using aggregate function in Datatable select Method
Hi,
I am also facing the same proble. The said solution works for MAX function but it is not working for sum(ColumnName).
Code:
DataSet ds = RepeaterProductInfo.DataSource as DataSet;
DataRow [] row = ds.Tables[0].Select("Sum(ItemPrice)");
strReturnValue = row[0][0].ToString();
But it is throwing Exception {"Filter expression 'Sum(ItemPrice)' does not evaluate to a Boolean term." }
I also tried following code,
Code:
DataSet ds = RepeaterProductInfo.DataSource as DataSet;
DataRow [] row = ds.Tables[0].Select("ItemPrice = Sum(ItemPrice)");
strReturnValue = row[0][0].ToString();
When I try this statement was not able to calculate sum though DataTable contains data.
Last edited by HanneSThEGreaT; June 17th, 2008 at 12:47 AM.
-
June 16th, 2008, 07:39 AM
#4
Re: Using aggregate function in Datatable select Method
Just a guess here but have you tried using as in the select statement?
"Select Sum(ItemPrice) as TotalPrice"
-
June 17th, 2008, 12:48 AM
#5
Re: Using aggregate function in Datatable select Method
shelar hemant, 2 things :
This thread is 3 years old, in future rather start your own thread.
It also looks like you are using C#, this is the VB.NET forum
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|