what is execute scalar?

Answer Posted / yograj pandey

Use the ExecuteScalar method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the ExecuteReader method, and then performing the operations that you need to generate the single value using the data returned by a SqlDataReader.

A typical ExecuteScalar query can be formatted as in the following C# example:

cmd.CommandText = "SELECT COUNT(*) FROM dbo.region";
Int32 count = (Int32) cmd.ExecuteScalar();

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is faster entity framework or ado.net?

506


Describe ado.net object model in detail.

536


What is execute scalar in ado.net?

502


Can we connect two dataadapters to same data source using single connection at same time?

535


What is ado.net and its architecture?

506






What is the meaning of executenonquery?

540


Explain the difference between data reader and data adapter?

509


What is the usage of the dataset object in ado.net?

491


What is the difference between Command and CommandBuilder object?

593


How would you connect to a database by using .NET?

484


How do you find the count of records in a dataset?

482


how to create a quiz software using 4 options to answer and how to check with answers in the database and award marks....

3724


What is ado.net connection?

471


What are the data access namespaces in .NET?

635


What are disadvantages of microsoft-provided data provider classes in ado.net?

508