Using ExecuteReader (for a single row, multiple columns):?
Short answer: SqlCommand command = new SqlCommand("SELECT CustomerName, ContactName FROM Customers WHERE CustomerID = @CustomerID", connection); command.Parameters.AddWithValue("@CustomerID", 1); connection.Open(); SqlDataReader reader = command.ExecuteReader();
Example code
if (reader.Read()) // Checks if there's data
{
string customerName = reader["CustomerName"].ToString();
string contactName = reader["ContactName"].ToString(); Console.WriteLine($"Customer: {customerName}, Contact: {contactName}"); } reader.Close(); connection.Close();
Real-world example (ShopNest)
ShopNest’s reporting job still uses ADO.NET for a heavy SQL query where raw performance and stored procedures matter more than EF convenience.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png