Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Possible Duplicate:
Linq To Sql - SQL Default Constraint Problem

My database table as a column called date_created defined as follows:

date_created DATETIME NOT NULL DEFAULT GETDATE()

I'm using Linq-to-SQL classes. I create a new object, populate it (omitting a value for date_created as that's supposed to sort itself out) and as soon as I call SubmitChanges it returns an error:

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

Any idea why? Thanks

share|improve this question

marked as duplicate by marc_s, Donal Fellows, V4Vendetta, tpeczek, j0k Nov 12 '12 at 12:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Did you define that property in your Linq-to-SQL model as "database generated"? Otherwise, Linq-to-SQL will still try to set the value.... easiest solution: just set the value date_created = DateTime.Now; in your code... –  marc_s Nov 12 '12 at 9:56
    
Well maybe since you omitted the value of the DateTime variable was set to DateTime.MinValue which would be causing it to throw the error –  V4Vendetta Nov 12 '12 at 9:59

1 Answer 1

up vote 2 down vote accepted

DUPLICATE ALREADY SOLVED

Thanks Hamlet Hakobyan who found the answer here: Linq To Sql - SQL Default Constraint Problem

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.