Command objects uses, purposes and their methods.

Answer

The command objects are used to connect to the Datareader or dataset objects with the help of the following methods:

ExecuteNonQuery:

This method executes the command defined in the CommandText property.
The connection used is defined in the Connection property for a query.
It returns an Integer indicating the number of rows affected by the query.

ExecuteReader:

This method executes the command defined in the CommandText property.
The connection used is defined in the Connection property.
It returns a reader object that is connected to the resulting rowset within the database, allowing the rows to be retrieved.

ExecuteScalar:

This method executes the command defined in the CommandText property.
The connection used is defined in the Connection property.
It returns a single value which is the first column of the first row of the resulting rowset.
The rows of the rest of the result are discarded.
It is fast and efficient in cases where a singleton value is required.

Command objects in ADO.NET - June 06, 2009 at 10:00 AM by Shuchi Gauri

Command objects uses, purposes and their methods.

Command objects are used to execute the queries, procedures. Sql statements etc. It can execute stored procedures or queries that use parameters as well.

It works on the basis of certain properties like ActiveConnection, CommandText, CommandType, Name etc.

Command object has three methods:

a) Execute: executes the queries, stored procedures etc.
b) Cancel: stops the method execution
c) CreateParameter: to create a parameter object

All ado.net Questions

Ask your interview questions on ado-net

Write Your comment or Questions if you want the answers on ado-net from ado-net Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---