In my database, I have NextStatDistanceTime value as a float. When \"float time = reader.GetFloat(0);
\" line excecuted, it gives an error of
while (reader.Read())
{
object initialTime = reader["NextStatDistanceTime"];
float time;
float.TryParse(initialTime.ToString(), out time);
totaltime = totaltime + time;
conn.Close();
}
Try this, this will get the time from the Database then convert it to a float, you can just put the reader["NextStatDistanceTime]
in the tryparse if you want but to make it clearer i have done it like this.
Any issues let me know