Command objects are used to connect a Connection object to a DataReader or DataSet. Following are the methods provided by a Command object:
ExecuteNonQuery
It executes the command that defined in the command text that defined in the connection property for a query that does not return any row (an UPDATE, DELETE, or INSERT).After executing it Returns an Integer indicating the number of rows affected by the query.
ExecuteReader
It executes the command that defined in the command text that defined in the connection property. It Returns a "reader" object that is connected to the resulting row set within the database, allowing the rows to be retrieved.
ExecuteScalar
It executes the command that defined in the command text that defined in the connection property
After executing it Returns only a single value (effectively the first column of the first row of the resulting row set, any other returned columns and rows are discarded). It is fast and efficient when only a "singleton" value is required.
Liked By
Write Answer
Explain the use of Command objects?
Join MindStick Community
You have need login or register for voting of answers or question.
Sunil Singh
30-Jun-2017Command objects are used to connect a Connection object to a DataReader or DataSet. Following are the methods provided by a Command object:
ExecuteNonQuery
It executes the command that defined in the command text that defined in the connection property for a query that does not return any row (an UPDATE, DELETE, or INSERT).After executing it Returns an Integer indicating the number of rows affected by the query.
ExecuteReader
It executes the command that defined in the command text that defined in the connection property. It Returns a "reader" object that is connected to the resulting row set within the database, allowing the rows to be retrieved.
ExecuteScalar
It executes the command that defined in the command text that defined in the connection property
After executing it Returns only a single value (effectively the first column of the first row of the resulting row set, any other returned columns and rows are discarded). It is fast and efficient when only a "singleton" value is required.