When I want to receive 3 values from the database.
16.5
15.5
15.5
With this code:
public static double calculateTotalPrice(int reserveringId)
{
double total=0;
int i = 0;
SqlCommand comm = sqlCrud.returnSqlCommand("select g.prijs from gerechten g inner join besteld b on b.gerechtId=g.gerechtId where b.reserveringId='"+reserveringId+"'");
SqlDataReader dt = comm.ExecuteReader();
if (dt.HasRows)
{
while (dt.Read())
{
total += dt.GetDouble(i);
i++;
}
}
return total;
}
It's telling me:
Additional information: Index was outside the bounds of the array.
What am I doing wrong?
Thanks
Aucun commentaire:
Enregistrer un commentaire