SqlDateTime Overflow Error
<note to self>
I have run into this problem a few times, but for some reason can never seem to remember the resolution. Therefore I decided to note it here for future reference.
When trying to insert a null value for a nullable datetime field in sql 2K, I end up getting the SqlDateTime Overflow error. This appears to be a problem with a difference between the definition of the Date and Datetime datatypes in .net and sql2K.
The way I found to solve this (there may be better and I would love to hear if there are) is:
if myDate = DateTime.MinValue then
myParamater.Value = System.DBNull.Value
else
myParamater.Value = myDate
end if
Please weigh in if you have any additional insight or a better solution, but this does seem to work.
</note to self>