SqlConnection con = new SqlConnection(strcon);DateTime dt = Convert.ToDateTime(txtfrom.Text);string fromDate = dt.ToShortDateString();DateTime dt1 = Convert.ToDateTime(txtto.Text);string toDate = dt1.ToShortDateString();SqlCommand cmdallltransactions = new SqlCommand("select sum(Amount) from AllTransactions where (TransCode <> 0) and (BranchKey = @BranchKey) and ((TransDate > @FromDate )and (TransDate < @ToDate)) GROUP by BranchKey", con);cmdallltransactions.CommandType = CommandType.Text;cmdallltransactions.Parameters.Add(new SqlParameter("@BranchKey", Convert.ToInt32(Session["BranchKey"])));cmdallltransactions.Parameters.Add(new SqlParameter("@FromDate", fromDate));cmdallltransactions.Parameters.Add(new SqlParameter("@ToDate",toDate));con.Open();decimal tot = 0;tot = Convert.ToDecimal(cmdallltransactions.ExecuteScalar());txttotal.Text = tot.ToString();con.Close();