One of the ways of enabling you to retrieve a single item from the database is,You run the ExecuteScalar() method against the command object in order to retrieve a single figure from the database. as shown in the example below
string connString = ConfigurationManager.ConnectionStrings["YourConnectionString"].ConnectionString; string queri = "SELECT COUNT(Orders) as dayOrders from Online_appointments";
using(SqlConnection conn = new SqlConnection(connString)) { using(SqlCommand cmd = new SqlCommand(queri,conn)) {
conn.Open(); int x = (Int)cmd.ExecuteScalar(); conn.Close();
return x;
} }Another way is by running a parameterized query where you seek exactly that item. so it all depends on exactly whats needed.