When a SqlCommand is ready with query or stored procedure, There is a SqlCommand property is required to execute and return the result from the database.
1. ExecuteNonQuery: ExecuteNonQuery method returns an integer specifying the number of rows inserted, deleted or updated.
SqlCommand cmd = new SqlCommand(); cmd.ExecuteNonQuery();
2. ExecuteReader: To return the result into a SqlDataReader.
SqlCommand cmd = new SqlCommand(); SqlDataReader dr = cmd.ExecuteReader();
3. ExecuteScalar: To return a single value from the query or stored procedure.
SqlCommand cmd = new SqlCommand(); cmd.ExecuteScalar("Query or stored procedure");