Analysis. Answer option B is correct.
The SqlCommand class represents a Transact-SQL statement or stored procedure to be executed at a SQL Server database. The ExecuteScalar method of the SqlCommand class is used to execute query commands that return a single value, such as an average, from a data source irrespective of the number of rows actually selected. It returns the first column of the first row in a resultset. Since it returns only a single value, it optimizes the performance of the query.
Answer options D and C are incorrect. The SqlDataAdapter class is used to represent a set of data commands and a database connection that fills a DataSet and updates a SQL Server database. It is used to retrieve and save data between a DataSet and a data source. The Fill method of the SqlDataAdapter class is used to add or refresh rows in a DataSet to match rows in the data source. This method can also be used to populate a DataSet object. The Update method of the DataAdapter class returns the number of rows that are successfully updated from a DataSet.
Answer option A is incorrect. The ExecuteReader method of the SqlCommand class is used to read records sequentially from a database.
== What is a stored procedure==
A stored procedure is a group of Transact-SQL statements compiled into a single
execution plan. A stored procedure can be used to implement business logic or
as a security mechanism, but it is not executed automatically. Stored procedures
provide better performance, as a fully compiled execution plan is created and
retained in the SQL Server procedure cache, when the stored procedure is created.
Hence, SQL Server does not have to recompile the execution plan every time the
procedure is executed.
