ADO.Net performance: ExecuteReader vs ExecuteNonQuery vs ExecuteScalar

Just re-linking a two year old blog post with performance advice that every developer using ADO.Net should read.

ExecuteReader, ExecuteNonQuery, ExecuteScalar … When to use What ?

Further notes:

  • Here is a good example (post #3) of how to implement OUTPUT parameters in a stored procedure using ExecuteNonQuery(), ignore post #2, he doesn’t know what he’s talking about.
  • Another example with just the ADO.Net side from MSDN: Executing a Command and Accessing Output Parameters.
  • The ExecuteNonQuery method returns the number of rows affected by the query (typically for Insert, Update, or Delete operations). From the MSDN page above.

Switch to our mobile site