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
ExecuteNonQuery()
is used when you are performing nonquery operations like insert, update or delete
, it can't be used for query operation like select
. In order to fetch records from DB
, use SqlDataReader
or SqlDataAdapter
but SqlDataReader
gives better performance. Have a look at this link describing SqlDataReader.