When trying to bring data from the DB to my dataGridView, several of these are null, so when I show it, it throws me the following
String '' was not recognized as a valid DateTime.
Create a class and put ?
so that it allows me null values, but it doesn't work
public DateTime? Fecha_inicio;
In the route of the While
, I have placed my code in this way to bring my data but it does not work it keeps telling meString '' was not recognized as a valid DateTime.
Fecha.Fecha_inicio = DateTime.Parse(reader[0].ToString(), null);
Fecha.Fecha_inicio = DateTime.ParseExact(reader[0].ToString(), "MM/dd/yyyy", null);
Fecha.Fecha_inicio = DateTime.ParseExact(reader[0].ToString());
How can I make my field Fecha_inicio
accept null values?
Hello you have to see if the value of the column is null or has value. If it is null put Start_Date in null and if it has value put the date
or if instead of null it is an empty string (it all depends on your query)