Command.ExecuteNonQuery() return always -1

后端 未结 4 1514
一生所求
一生所求 2021-01-25 04:35

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

4条回答
  •  天涯浪人
    2021-01-25 04:59

    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.

提交回复
热议问题