I’m trying to save a TimeSpan variable from VB into a SQL database, into a non-null column.
It works fine for other values, but when I try to save 00:00:00 I am told that I cannot save NULL into a non-null column…
Is there a way to get it to actually save this rather than think that it’s NULL?
Cheers
Note: This code is a method in a class, which has a property:
Private mCommand As New SqlCommand
Dim Param As New SqlParameter
Param.ParameterName = "@" + ParameterName
Param.SqlDbType = SqlDbType.VarChar
If Value Is Nothing Then
Param.Value = DBNull.Value
Else
Param.Value = Value
End If
Param.Size = Size
Param.Direction = Direction
mCommand.Parameters.Add(Param)
It looks like it’s impossible to differentiate between if 00:00:00 is actually the value, or if it should be seen as Nothing.
I have therefore removed the check for Nothing in the code i posted above, and left it as just