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

What is ado.net full form?

546


What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

552


What is a string variable?

478


What are different layers of ADO.Net?

578


How to load multiple tables into a dataset?

534






What does ado stand for in ado.net?

448


What is fill method in ado.net?

533


List all the steps in order, to access a database through ado.net?

576


What are the advantages of oledb compared with other classes?

2316


How can we perform transactions in .net?

534


What is csdl entity framework?

546


What is an example of ordinal data?

483


Can you explain how to enable and disable connection pooling?

498


Explain the overview of ado.net architecture?

510


How to bind the controls(best practice) comboboxes to the data in the dataset?

533