Monday 15 June 2015

c# - Datatable.Compute Runtime Error -


I want to get the maximum value from a column in the data table!

My data table value

  column 1 date column 2 column 3 column 4 power (kWh) 06 / June / 2013 00:00:00 99.00 43.00 56.00 power (kilowatt ) 14 / Jun / 2013 00:00:00 260.00 48.00 212.00   

When I enter the code

 , then double click here = convert. Double (dtChart.Compute ("MAX (Column2)", "")); Value of variable A is 260   

but when = DtChart.Columns [i] .Caption; // A value is 'column 2'; Double max-valve = convert. ToDouble (dtChart.Compute ("MAX" ("" + "+" "" "", ""));}

It shows that " "Syntax error in all arguments: expecting a single column argument with the potential 'hair' qualifier. What do I suspect because you are quoting it here:

  "MAX ('+ a + Then you need it:  
  "MAX (" + a) " + ")"   

or:

  string.Format ("MAX ({0})", a)    

No comments:

Post a Comment