I am trying to assign 'null' value to Datetime? object. But it is throwing "nullable value must have a value" exception.
//item.PlannedStartDate value is nothing.
fact_Initiative.Start_Date = If([String].IsNullOrEmpty(item.PlannedStartDate),
DBNull.Value, CType(Convert.ToDateTime(item.PlannedStartDate),
System.Nullable(Of Date)))
How to solve this
fact_Initiative.Start_Date =If(String.IsNullOrEmpty(item.PlannedStartDate), CType(Nothing, DateTime?), DateTime.Parse(item.PlannedStartDate))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With