Dodsworth
asked on
An overflow occurred while converting to datetime.
I'm trying to write a record to SQL CE using Linq to SQL and getting the following error message....
System.Data.SqlServerCe.Sq lCeExcepti on: An overflow occurred while converting to datetime
Curiously, I'm not actually inserting a value into the DateTime field.
If I remove the DataTime attribute from my class then all is well.
Help (please) !
System.Data.SqlServerCe.Sq
Curiously, I'm not actually inserting a value into the DateTime field.
If I remove the DataTime attribute from my class then all is well.
Help (please) !
try this format for the date yyyymmdd
ASKER
I'm not even writing a date to the table !
your Linq2Sql class that holds the Column names has a DateTime column set correct?
Example:
I would reccomend changing to this:
Example:
[Table(Name="Blah")]
public class MyTable
{
[Column(Name="MyDate" canbenull=true)]
public DateTime MyDate{get;set;}
}
I would reccomend changing to this:
[Column(Name="MyDate" canbenull=true)]
public DateTime? MyDate{get;set;} //declare DateTime value as nullable
ASKER
I'm using VB.net
<Column> _
Public Property sStartDate() As DateTime
Get
Return m_sStartDate
End Get
Set(value As DateTime)
m_sStartDate = value
End Set
End Property
Private m_sStartDate As DateTime
I tried <Column(DbType="DateTime", CanBeNull = True)
but still no good :(
<Column> _
Public Property sStartDate() As DateTime
Get
Return m_sStartDate
End Get
Set(value As DateTime)
m_sStartDate = value
End Set
End Property
Private m_sStartDate As DateTime
I tried <Column(DbType="DateTime",
but still no good :(
ASKER
Anyone?
I usually see that message when the datetime being passed is outside of the range accepted by the database. Common if data has been converted from ACcess or similar - or there is a typo in the date and 2013 has been entered as 201.
Is nearly always a data issue.
Kelvin
Is nearly always a data issue.
Kelvin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fixed