I am trying to store a null value into a DateTime column. My code is like below:
protected void btnInsert_Click(object sender, EventArgs e)
{
try
{
ChangeModule cm = new ChangeModule();
cm.CR_REF_NO = txtCRRefNumber.Text.Trim();
cm.SLA_DELIVERY_DATE_WAIVER = DateTime.ParseExact(txtSLADeliveryDateWaiver.Text, "dd/MM/yy", null);
else /*This else part is causing problem since I assigned null*/
cm.SLA_DELIVERY_DATE_WAIVER = null;
}
catch (Exception ex)
{
throw ex;
}
}
Code is working fine as long as a proper date exists in SLA_DELIVERY_DATE_WAIVER, but throwing error when there is the blank textbox.