ExecuteNonQuery for SELECT sql statement returning no rows

前端 未结 4 1763
时光取名叫无心
时光取名叫无心 2020-11-27 07:17

how do you check for no rows returned after ExecuteNonQuery for SELECT sql statement returns no rows??

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 07:55

    Use the ExecuteReader method instead. This returns a SqlDataReader, which has a HasRows property.

    ExecuteNonQuery shouldn't be used for SELECT statements.

提交回复
热议问题