What is the use of command objects and what are the methods provided by the command object ?

They are used to connect connection object to Datareader or dataset. Following are the methods provided by command object

ExecuteNonQuery :- Executes the command defined in the Command Text property against the connection defined in the Connection property for a query that does not return any row (an UPDATE, DELETE or INSERT). Returns an Integer indicating the number of rows affected by the query.

ExecuteReader :- Executes the command defined in the CommandText propertyagainst the connection defined in the Connection property. Returns a "reader"object that is connected to the resulting rowset within the database, allowing the rows to be retrieved.

ExecuteScalar :- Executes the command defined in the CommandText propertyagainst the connection defined in the Connection property. Returns only single value (effectively the first column of the first row of the resulting rowset) any other returned columns and rows are discarded. It is fast and efficient when only a "singleton" value is required.

Questions by robindas   answers by robindas

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions