转换数据类型时发生日期时间溢出

时间:2014-05-20 17:08:27

标签: vb.net datetime windows-phone type-conversion localdb

我在Windows Phone上使用localDB,我想使用datetime。每次我都会收到错误

An exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.Linq.ni.dll but was not handled in user code
内部异常中的

When converting data type datetime overflow occurred.

简单定义列(VB.NET)

<Column(CanBeNull:=True)>
Public Property Expiration As DateTime

为什么我每次都会遇到错误转换数据类型时会发生日期时间溢出?

1 个答案:

答案 0 :(得分:1)

我会确保数据库中的日期不在您的编程语言中的数据类型的上限或下限之外(忘记它是什么)。一个例子是Microsoft的SQL服务器的最小日期时间小于C#中的最小日期时间,如果不考虑这个,则会导致错误。

另外,显然确保数据库对象不为空。