I'm trying to get Double type values from an sql datareader, so all right, it happens that when I do a dr.getDouble (2) it gives me invalid cast exception.
System.InvalidCastException: 'Unable to convert an object of type' System.Byte [] 'to type' System.IConvertible '.'
I make a query mysql would be something of the style:
Select str1, 'un alias cualquiera', count(*)
from tabla
where valor > 30 and str1 like('Algo')
group by str1
union
Select str1, 'un alias cualquiera', count(*)
from tabla
where valor > 40 and str1 like('Algo')
group by str1
union
...
Table of values
+-----------+--------------+---------+
| String | Alias | 1.92 |
+-----------+--------------+---------+
| String | Alias | 98 |
+-----------+--------------+---------+
| String | Alias | 43.23 |
+-----------+--------------+---------+
This is what I try in my code.
MySqlConnection conn = null;
MySqlCommand consulta = null;
MySqlDataReader dr;
Double val;
inicializarconexion(conn, consulta); //hasta aquí ningún problema.
val = dr.getDouble(2); //Aquí salta la excepción.
Capture of the count (*)