The specified conversion error is not valid in the code:
if (command.ExecuteScalar() == DBNull.Value)
{
resultados[j2][i2] = 0;
}
else
{
resultados[j2][i2] = (double)(decimal)command.ExecuteScalar(); /* <<---- */
}
The query I'm running in mysql is:
SELECT IFNULL(AVG(VL_M4000010),0)
FROM HT_MA4_ESS_SEG
WHERE YEAR(TS_SAMPLETM) = 2015
AND MONTH(TS_SAMPLETM) = 1
AND TIME(TS_SAMPLETM)
BETWEEN '00:00:00' AND '00:15:00'
The result of query via MySQL Workbench is 0
.
I've tried converting (decimal)
to only (double)
, so it would be (double)command.ExecuteScalar();
.