Link to home
Start Free TrialLog in
Avatar of Dodsworth
Dodsworth

asked on

Linq to SQL Insert Problem

I have an entity class as below, but when I try to add a new row without specifying an EndDate, I get the error..

System.Data.SqlServerCe.SqlCeException: An overflow occurred while converting to datetime

If I add a row with an EndDate then all is fine.

<Table> _
Public Class Notes

    <Column(IsDbGenerated:=True, IsPrimaryKey:=True)> _
    Public Property Id() As Integer
        Get
            Return m_Id
        End Get
        Set(value As Integer)
            m_Id = value
        End Set
    End Property
    Private m_Id As Integer

    <Column> _
    Public Property StartDate() As System.Nullable(Of Date)
        Get
            Return m_StartDate
        End Get
        Set(value As System.Nullable(Of Date))
            m_StartDate = value
        End Set
    End Property
    Private m_StartDate As DateTime

    <Column(CanBeNull:=True)> _
    Public Property EndDate() As System.Nullable(Of Date)
        Get
            Return m_EndDate
        End Get
        Set(value As System.Nullable(Of Date))
            m_EndDate = value
        End Set
    End Property
    Private m_EndDate As DateTime

    <Column> _
    Public Property Note() As String
        Get
            Return m_Note
        End Get
        Set(value As String)
            m_Note = value
        End Set
    End Property
    Private m_Note As String
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dodsworth
Dodsworth

ASKER

Yes that's fixed it thanks. Strange as the code was generated by SQLMetal.