How to pass the null value to datetime datatype in asp.net?
cmdInsertUpdateConsultantDetails.Parameters.Add("@DateofExpiry", SqlDbType.DateTime);
if (txtdateofexpiry.Text.Trim() == "")
{
cmdInsertUpdateConsultantDetails.Parameters["@DateofExpiry"].Value =
}
else
{
cmdInsertUpdateConsultantDetails.Parameters["@DateofExpiry"].Value =
Convert.ToDateTime(txtdateofexpiry.Text.Trim());
}
Simple here you can give
DbNull.Valueto passNULLvalue.It’s also recommended the use of
DateTime?or Nullable