2013年1月2日 星期三

[c#] error converting data type datetime to smalldatetime


stackoverflow

SQLServer's datetime datatype is a much smaller range of allowed values than .net datetime datatype. SQLServer's datetime type basically supports the gregorian calendar, so the smallest value you can have is 1/1/1753. In 2008 SQLServer added a datetime2 datatype that supports back to year 1 (there was no year 0). Sounds like you're trying to insert a datetime value that's before 1/1/1753 into a datetime (not datetime2) SQLServer column.

所以就直接檢查 C# DateTime 有沒有超過 MSSQL SMALLDATETIME 上下界,若超過就縮進去,反正這玩意撐個十年就很了不起了。

沒有留言:

張貼留言