You want to retrieve a single value (e.g., the total number of records) from a SELECT statement. Which ADO.NET method would you use for this purpose?
- ExecuteScalar
- ExecuteNonQuery
- ExecuteReader
- ExecuteXmlReader
The correct option is ExecuteScalar. This method is used to execute a query that returns a single value, such as a count, sum, or average. It is commonly used when you need to retrieve aggregate information from the database without fetching a full result set.
Loading...
Related Quiz
- In ADO.NET, what is the role of parameters in non-query commands?
- In LINQ to Entities, what does "Entities" refer to?
- Scenario: You are tasked with developing a web application that collects user input and inserts it into a SQL Server database. How can you prevent SQL injection in this scenario?
- In LINQ to DataSet, what is the purpose of the join clause?
- Explain the concept of optimistic concurrency in LINQ to SQL.