ExecuteNonQuery returns number of effected records in table - ADO.NET -
Q. Which SqlCommand execution returns the number of effected records in the table?- Published on 31 Aug 15a. ExecuteNonQuery
b. ExecuteReader
c. ExecuteXmlReader
d. ExecuteScalar
ANSWER: ExecuteNonQuery
EecuteScalar method of SqlCommand object returns the value of the first column of the first row from a table.
The common methods of command abject are as follows.
• ExecuteReader: This method works on select SQL query. It returns the DataReader object. Use DataReader read () method to retrieve the rows.
• ExecuteScalar: This method returns single value. Its return type is Object.If you call ExecuteScalar method with a SQL statement that returns rows of data, the query returns only the first column of the first row.
• ExecuteNonQuery: If you are using Insert, Update or Delete SQL statement then use this method. Its return type is Integer (The number of affected records).