Reputation: 6014
I have a strange problem and something that I haven't come across before. I have a mysql query like the one below
SELECT COUNT( * ) AS total_count FROM postcodes WHERE prefix='M1';
My query matches one row so I am expecting the value of total_count to be 1. However instead it is returning -1. Does anyone know why if would be returning a negative value?
Upvotes: 5
Views: 3217
Reputation: 8690
Did you use ExecuteNonQuery
instead of ExecuteScalar
? Or in more general terms, did you read the row count instead of the result [in the first column of the first row]?
That's what I did to get a -1
. Oops.
Upvotes: 0