raphael232
Programmer
Hi, i'm having trouble dealing with null dates. For example first i pass my date as a string to my business layer. Then before i do my update i do the following to my date:
I was hoping if the string wasn't blank it would pass a date and if it was it would pass null. However this does not work.
Also i have another scenario when instead of a string i have a date already parsed. I tried directly updating from this but it did not like it when the type was value was type DBNull. Therefore i added:
before the update but this returns an exception and the update is not carried out.
Appreciate if someone could help.
Thanks
Code:
If inputDate <> "" Then inputDate = DateTime.Parse(inputDate) Else inputDate = Nothing
I was hoping if the string wasn't blank it would pass a date and if it was it would pass null. However this does not work.
Also i have another scenario when instead of a string i have a date already parsed. I tried directly updating from this but it did not like it when the type was value was type DBNull. Therefore i added:
Code:
If document.InputDate.GetType Is DBNull.Value Then inputDate = Nothing Else inputDate = document.InputDate
before the update but this returns an exception and the update is not carried out.
Appreciate if someone could help.
Thanks