0

when i try to run my solution roject i get this erro mesage on this line code

System.InvalidCastException: 'Object cannot be cast from DBNull to other types.'

 if (Convert.ToInt32(dr["Visitas"]) == null)
                        {
                            visitas = 0;
                        }
  • Note that an integer *can't* be `null`, so this comparison would never be able to work anyway. It looks like your intent is to compare `dr["Visitas"]` with `DBNull`, no conversion necessary. – David Feb 17 '23 at 20:15

0 Answers0