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
How is entity framework different from ado.net?
Is datareader faster than datatable?
oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?
What is ado.net tutorial?
What is namespace in ado.net?
What is difference in record set and dataset?
What is ado oledb and odbc?
Explain how to call the sql commands asynchronously in ado.net version 2.0?
Is ado.net dead?
What is openrowset?
Can datareader hold data from multiple tables?
How to bind the controls(best practice) comboboxes to the data in the dataset?
What does ado stand for in ado.net?
What are the pre-requisites for connection pooling?
What are the advantage of ado.net?