Command objects uses, purposes and their methods.

Command objects uses, purposes and their methods.

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 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:

1) Execute : Executes the queries, stored procedures etc.
2) Cancel : Stops the method execution.
3) CreateParameter : To create a parameter object.
Difference between dataset and datareader.
DataSet object can contain multiple rowsets from the same data source as well as from the relationships between them.......
.NET Mobile overview
.NET Mobile overview - .NET Mobile is a platform for developing applications for mobile phones. It’s an extension to .NET Framework and is called Microsoft Mobile Internet Toolkit.......
Pros and cons of LINQ (Language-Integrated Query)
Pros and cons of LINQ - Stored procedures normally are faster as they have a predictable execution plan. Therefore, if a stored procedure is being executed for the second time......
Post your comment