Command.ExecuteNonQuery() return always -1

后端 未结 4 1509
一生所求
一生所求 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 05:12

    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.

提交回复
热议问题