Feb 13, 2009 03:06 AM|Mikesdotnetting|LINK
I have the code below for the count but it always return 1
As Hans said, you should use ExecuteScalar() or ExecuteReader() to return single or multiple values respectively. The only thing that ExecuteNonQuery() returns is the number of rows that have been affected by the query, which in your case will always be
A minor amendment to Hans' final line of code:
ExecuteScalar() returns an object, so it needs to be cast to the correct type.