blog

Home / DeveloperSection / Blogs / ExecuteNonQuery, ExecuteReader and ExecuteScalar Methods in C#

ExecuteNonQuery, ExecuteReader and ExecuteScalar Methods in C#

AVADHESH PATEL7942 17-Jan-2013
ExecuteNonQuery Method:

This method is commonly used for update, insert and delete statements, where the only returned value is the number of record affected.

Namespace: System.Data.SqlClient

Assembly: System.Data (in System.Data.dll)

Return Value Type: System.Int32

ExecuteReader Method:

This method executes the command and returns a typed data reader object, depending on the provider is used. The object returned can be used to iterate through the record(s) returned.

Namespace: System.Data.SqlClient

Assembly: System.Data (in System.Data.dll)

Return Value Type: System.Data.SqlClient.SqlDataReader

ExecuteScalar Method:

Execute the command and return a single value. On many occasions, it is necessary to return a single result from a SQL statement, such as the count of records in a given table, or the current data time of the server.

Namespace: System.Data.SqlClient

Assembly: System.Data (in System.Data.dll)

Return Value Type: System.Object


Updated 18-Sep-2014
Avadhesh Kumar Patel District Project Manager - Aligarh 14 months work experience in Panchayati Raj Department Sector as District Project Manager & 12 months work experience in IT Sector as Software Engineer. :-)

Leave Comment

Comments

Liked By