How to get sum of numbers using SQL query in ASP.NET C#?
<p>I am beginner in ASP.NET Web Development.Now I want to find sum of marks using SQL sum query. but It finds -1 as sum after query execution. Here is my code:    </p>

<pre><code>public double GetTotalScore(string regNo)
{
    SqlConnection connection=new SqlConnection(ConnectionString);
    string query = "select sum(Score) from SaveResult where RegNo='" + regNo + "' group by RegNo";
    SqlCommand command = new SqlCommand(query, connection);
    connection.Open();
    double total = command.ExecuteNonQuery();
    connection.Close();
    return total;
} 
</code></pre>

<p>How could i get sum using sql query?</p>