- I have variable called modifieddate of type DateTime, which can be set to null.
- I fill in the variable using a datareader and set the value to nothing if the reader is empty
- when I use the variable further down, the store procedure complaints that I am not providing the value. "Procedure or function 'tHistory_Insert' expects parameter '@modifieddate', which was not supplied"
Question: Any ideas on how to pass null values into the store procedure when the date in empty?
Step 1
Public modifieddate As Nullable(Of DateTime)
Step 2
If IsDBNull(dr("modifieddate")) = False Then
modifieddate = DateTime.Parse(dr("modifieddate"))
Else
modifieddate = Nothing
End If
Step 3
command.Parameters.Add("@modifieddate", SqlDbType.DateTime).Value = modifieddate
command.ExecuteNonQuery()