I am trying to read the values out of a database that I am aware is null in the criteria I am looking for right now.
So I had this method of checking for that: ld.Percentage = reader["DataWin3Data"] != DBNull.Value ? Convert.ToDouble(reader["DataWin3Data"]) : double.MinValue;
I have used it before where a field can be null and it hasn't had a problem. I am not totally sure what to do in this situation as to how to fix it. I have included my relevant code below. How can change what I am doing currently to not have have this error when there is a null value?
ld.Percentage = reader["DataWin3Data"] != DBNull.Value ? Convert.ToDouble(reader["DataWin3Data"]) : double.MinValue;
ld.TotalCases = reader["DataWin8Data"] != DBNull.Value ? Convert.ToInt32(reader["DataWin8Data"]) : int.MinValue;
ld.TotalPercentage = reader["DataWin7Data"] != DBNull.Value ? Convert.ToDouble(reader["DataWin7Data"]) : double.MinValue;
Double.TryParseinstead? More lines of code perhaps, but safer. - DonBoitnott