I have a problem when I executed Select command in C# using ExecuteNonQuery() method; It always return -1; This means that no record returned by the selected statement, doesn\'t
You shouldn't execute a SELECT with an ExecuteNonQuery()
. It is called ExecuteNonQuery because you want something to execute that is not a query. A SELECT
is a query. You want to ExecuteReader. If you want to do an UPDATE
or DELETE
, then you can do an ExecuteNonQuery()
and that will show how many rows were affected.