ASP.NET ExecuteScalar

ExecuteScalar method uses to retrieve a single value from a database. The ExecuteScalar() executes SQL statements as well as Stored Procedure and returns the first column of the first row in the result set, or a null reference if the result set is empty.



It is very useful to use with aggregate functions like Count(*) or Sum() etc. When compare to ExecuteReader() , ExecuteScalar() uses fewer System resources.

The following ASP.NET program find number of rows in the author table using ExecuteScalar method.


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.vb (C) 2021    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About