I have a data table and a column contains int values. I have not specified the column with any datatype. When I perform the following.
object sum = dttest.Compute("sum(Value)", "");
I am getting below error.
Invalid usage of aggregate function Sum() and Type: String.
And I tried converting column value to int using
object sum = dttest.Compute("sum(Convert(Value, 'System.Int32'))","");
again I am getting another error
Syntax error in aggregate argument: Expecting a single column argument
with possible 'Child' qualifier.
When I specify the datatype for the column, first code will return correct value. But in my case I can't specify column datatype. Any one having solution ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…