Monday 9 December 2013

Differences between ExecuteReader, ExecuteNonQuery AND ExecuteScalar

Differences between ExecuteReader, ExecuteNonQuery AND ExecuteScalar


Introduction:

In this article I will explain differences between executereader, executenonquery and executescalar inasp.net.

Description:

In previous posts I explained difference between Len and DataLength functionsdifference between int,tinyint and bigint and differences between char, varchar and nvarchar in SQL Server. Now I will explain difference between executereader, executenonquery and executescalar in asp.net

ExecuteNonQuery

ExecuteNonQuery method will return number of rows effected with INSERT, DELETE or UPDATE operations.This ExecuteNonQuery method will be used only for insert, update and delete, Create, and SETstatements. (Read More)

ExecuteScalar

Execute Scalar will return single row single column value i.e. single value, on execution of SQL Query or Stored procedure using command object. It’s very fast to retrieve single values from database. (Read More)

ExecuteReader

Execute Reader will be used to return the set of rows, on execution of SQL Query or Stored procedure using command object. This one is forward only retrieval of records and it is used to read the table values from first to last. (Read More)

No comments:

Post a Comment