Dave Balzer

Confessions of a Webgypsy

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Blog Roll

Subscriptions

Post Categories



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>

posted on Wednesday, June 15, 2005 12:49 PM by dbalzer





Powered by Dot Net Junkies, by Telligent Systems