C# .NET - Datatable compute not working - Asked By sunil p on 11-Jul-12 07:31 PM

Hi,

I want to Sum the datatable column value.I am using Copmute method to achive this.

HiddenField.value=dt.Compute("sum(columnname)",string.Empty).Tostring();

But i am getting this error message"Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier"

Please anybody resolve this problem

Thanks,
sunil
Jitendra Faye replied to sunil p on 12-Jul-12 02:27 AM
Check the syntax for compuet() mthod

refer this link-

http://msdn.microsoft.com/en-us/library/system.data.datatable.compute.aspx

private void ComputeBySalesSalesID(DataSet dataSet)
{
    // Presumes a DataTable named "Orders" that has a column named "Total."
    DataTable table;
    table = dataSet.Tables["Orders"];

    // Declare an object variable.
    object sumObject;
    sumObject = table.Compute("Sum(Total)", "EmpID = 5");
}