Check if record in a table exist in a database through ExecuteNonQuery

前端 未结 5 468
心在旅途
心在旅途 2020-12-03 14:06

in my program i need to check if a record in the database already exists in the table using the if statement. using c# i am trying to do this through an sql con

5条回答
  •  孤街浪徒
    2020-12-03 14:31

    You should be using ExecuteScalar for cheking if the record exists. ExecuteNonQuery runs a transact-SQL statement against the connection and returns the number of rows affected for an UPDATE, INSERT, or DELETE. It doesn't apply for SELECT statements

提交回复
热议问题