I explain, I have a query in SQL that returns me sometimes Int's and sometimes Doubles
+--------+-----------+
| Algo | Resultado |
+--------+-----------+
| Algo1 | 521 |
+--------+-----------+
| Algo2 | 5.12 |
+--------+-----------+
| Algo3 | 0 |
+--------+-----------+
I clarify since I can not change the query.
What I used to do was.
Byte[] val;
while(dr.read()){
val = System.Text.Encoding.UTF8.GetBytes(dr.GetValue(2).ToString());
objeto.setValor(System.Text.Encoding.Default.GetString(val));
}
The other class:
class Objeto
{
private double valor;
//otros atributos
public void setValor(String valor)
{
this.valor = Double.Parse(valor, System.Globalization.CultureInfo.InvariantCulture);
}
And it used to work for me, but now I do not know why he says it to me
System.FormatException : 'The input string does not have the correct format.'
The query returns two types of data because it's something like this:
SELECT Count(*)
FROM Tabla
UNION
SELECT AVG(valores)
FROM Tabla
I clarify again that I can not modify it