Insert a datetime causes error
Posted: Wed 07 Dec 2011 08:24
I have a table USER contains:
ID int,
NAME varchar(50),
CREATED datetime default getdate()
It throw an error LinqCommandExecutionException (SqlDateTime overflow) while I did this:
USER user = new USER();
user.ID = 1;
user.NAME = "AAA";
// user.CREATED is not provided, so it will use default value(getdate())
dataContext.USERs.InsertOnSubmit(user);
dataContext.SubmitChanges(); // Error
How can I Insert a row without provide a column with default value(getdate())?
ID int,
NAME varchar(50),
CREATED datetime default getdate()
It throw an error LinqCommandExecutionException (SqlDateTime overflow) while I did this:
USER user = new USER();
user.ID = 1;
user.NAME = "AAA";
// user.CREATED is not provided, so it will use default value(getdate())
dataContext.USERs.InsertOnSubmit(user);
dataContext.SubmitChanges(); // Error
How can I Insert a row without provide a column with default value(getdate())?