cmd = new SqlCommand("select SUM(ISNULL(amount,0)) AS total from amount", con);
dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
if (dr[0] != DBNull.Value)
{
total = Convert.ToSingle(dr[0]);
}
else
total = 0;
float f = total + float.Parse(TextBox1.Text);
dr.Close();
cmd = new SqlCommand("insert into amount(amount,total)values('" + TextBox1.Text + "','" + f + "')", con);
cmd.ExecuteNonQuery();
TextBox1.Text ="";
Response.Write("<script>alert('Successfull');</script>");
}
else
{
dr.Close();
}