Junior From PDF ADO.NET ADO.NET

What is the difference between ExecuteNonQuery, ExecuteReader, and ExecuteScalar?

Short answer: ExecuteNonQuery: Executes SQL commands that do not return data (e.g., INSERT, UPDATE, DELETE).

Example code

command.ExecuteNonQuery(); (used to insert a record). ExecuteReader: Executes SQL commands that return rows (e.g., SELECT queries). It returns a DataReader. Example: command.ExecuteReader(); (used to select records). ExecuteScalar: Executes SQL commands and returns a single value (e.g., a single cell of data). Example: command.ExecuteScalar(); (used for retrieving the count or aggregate values).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details