I have this short code which I use to read data into maskedtextbox and then (which isn't part of this code) UPDATE them via SqlCommand
SqlCommand novyprikaz = new SqlCommand("SELECT * FROM zajezd WHERE akce=" + tentoradek, spojeni);
spojeni.Open();
SqlDataReader precti = novyprikaz.ExecuteReader();
if (precti.Read())
{maskedTextBox2.Text = precti.GetDateTime(24).ToShortDateString(); // i need to improve this part
}
But know if maskedTextBox2
value is NULL it gives me an error that:
Data is Null. This method or property cannot be called on Null values.
I would like to ask you, what should I change with this code to make it read Null? Thanks in advance.
Here is the snippet of the code which I used to do for INSERT INTO
It is marked as an answer.