2

My code is like this, but it gives an error:

//array_field is an array of double values 
NpgsqlCommand Command = new NpgsqlCommand("SELECT array_fied from atable"); 
NpgsqlDataReader dr = Command.ExecuteReader(); 
while (dr.Read()) 
{
    double[] rrr = dr.GetDouble(dr.GetOrdinal("array_field")); 
}

The error message is: cannot implicitly convert 'double' to 'double[]'. I tried other variations as well which also didn't work.

thanks for your help Judit

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Judit
  • 114
  • 1
  • 3
  • 10
  • double[] is an array. dr.GetDouble lloks like a single double. – Valamas Sep 06 '13 at 09:58
  • Have you tried `GetValue` with a cast to `double[]`? `GetDouble` will only return `double`, not `double[]`. I'm only guessing as it would rely on the `NpgsqlDataReader` being able to return arrays. This question explores it: http://stackoverflow.com/questions/7150873/postgres-bytea-column-is-returning-string-char-array-instead-of-byte-array – Adam Houldsworth Sep 06 '13 at 09:58
  • You misspelled array_field or array_fied , anyhow they don't match – Jaycee Sep 06 '13 at 10:00

1 Answers1

6
Double[] rrr = dr["array_field"] as Double[];
SteinIP
  • 376
  • 4
  • 5