Command Object Methods - ADO.NET

Q.  What are the Command Object Methods?
- Published on 16 Jun 15

a. ExecuteNonQuery
b. ExecuteReader
c. ExecuteScalar
d. All of the above.

ANSWER: All of the above.
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 executes but returns only the first column of the first row returned by the query.

- 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).

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)