Работа со значениями DateTime и Null
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"
Вопрос: Есть идеи, как передать нулевые значения в процедуру хранения, когда дата пуста?
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()