What is the Difference between ExecuteNonQuery,ExecuteReader and ExecuteScalar

Advertisement
ExecuteNonQuery:

ExecuteNonQuery will work only with Action queries like Create,Insert,Update,Delete,Alter,drop.

It is having return type Int.

It will returns the count of rows effected by the query.

It executes the command defined in the Command text property.


ExecuteReader:

ExecuteReader will work with action and non-action queries.

It is having return type is DataReader.

It will returns the collection of rows selected by the query.

It executes the command defined in the Command text property.


ExecuteScalar:

ExecuteScalar will work with Non action queries that contain aggregate functions.

It is having return type Object.

It results the first row and first column value of the query result.

It is fast and efficient when only a singleton value is required.

It executes the command defined in the Command text property.





Advertisements
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment