When a query return single value from database, The ExecuteScalar Method is used. In such cases Sql Statements like Finding no of records, finding Maximum value from table. And then performing the operations necessary to generate the single value. Other Columns Value or rows are ignored.
This would be easy for receiving a records in an sql statement, or for any query where only one specific field in one column is needed.
cmd.CommandText = "select count(*) from projects";
Int32 count1 = (int32) cmd.ExecuteScalar();