Can someone help me fix my code I am trying to put null in sql server through a function that is excepting _dtSWO.
If I set _dtSWO = Nothing it returns #12:00:00 AM# which throws an exception. The field is nullable in sql server I just want it to return a blank
Dim _swoDate As String = udSWOReceivedDateDateEdit.Text
Dim _dtSWO As Date
If _swoDate <> "" Then
_dtSWO = Date.Parse(udSWOReceivedDateDateEdit.Text)
Else
'THIS DOESNT WORK
_dtSWO = Nothing
End If
You need to use a Nullable type. By default, Date does not except null (Nothing in VB.Net) as a value. Nullable types do accept null (Nothing).
Edited based on the comment.