Date field issue

Topics: Customizing Orchard
Nov 20, 2011 at 12:02 PM

Hi,

When i try to add data my date fileds return error

{"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}

 

This is my modle

 public virtual DateTime    DateListed { get; set; }
        public virtual DateTime DatePublished { get; set; }
        public virtual int CategoryID { get; set; }
        public virtual int SponsorID { get; set; }
        public virtual string  ArticlesName { get; set; }
        public virtual bool  IsPublished { get; set; }
        public virtual string  Publisher { get; set; }
        public virtual string  Source { get; set; }
        public virtual string  Lead { get; set; }
        public virtual DateTime  StartDate { get; set; }
        public virtual DateTime  EndDate { get; set; }
        public virtual bool IsTop { get; set; }
        public virtual bool IsArchive { get; set; }
        public virtual bool  UseImage { get; set; }
        public virtual bool MembersOnly { get; set; }
        public virtual bool UseHeaders { get; set; }
        public virtual string  Content { get; set; }

lakmal

Coordinator
Nov 20, 2011 at 9:59 PM

The error message is perfectly clear, I think What date value did you try to set?

Nov 21, 2011 at 2:05 AM

I tried to this value  05/05/2005

 

Nov 21, 2011 at 2:10 AM

The problem might be that you didn't fill in all your dates. If any are optional, make them nullable.

Nov 21, 2011 at 2:21 AM

I have filled all dates

 

Nov 28, 2011 at 11:36 AM

Hello did you resolve this error? I am getting the same issue.

Nov 28, 2011 at 12:36 PM

Not yet, If you find solution let me know

 

Nov 30, 2011 at 2:02 PM

I have found solution. I have update my model like below with  ? mark

 

 public virtual DateTime ?    DateListed { get; set; }
        public virtual DateTime ? DatePublished { get; set; }
        public virtual int CategoryID { get; set; }
        public virtual int SponsorID { get; set; }
        public virtual string  ArticlesName { get; set; }
        public virtual bool  IsPublished { get; set; }
        public virtual string  Publisher { get; set; }
        public virtual string  Source { get; set; }
        public virtual string  Lead { get; set; }
        public virtual DateTime ? StartDate { get; set; }
        public virtual DateTime ? EndDate { get; set; }
        public virtual bool IsTop { get; set; }
        public virtual bool IsArchive { get; set; }
        public virtual bool  UseImage { get; set; }
        public virtual bool MembersOnly { get; set; }
        public virtual bool UseHeaders { get; set; }
        public virtual string  Content { get; set; }

now its working find

lakmal
http://www.odesk.com/users/ASP-NET-Web-application-Designer-DotNetNuke-Expert_~~4fc245f3b8e64e9b