datetime issue with 01/01/1900

后端 未结 3 1740
慢半拍i
慢半拍i 2020-12-16 21:17

i have a datetime column in sql server and its optional field and if the user decided not to enter then i want to insert the value as NULL in the table and i define somethin

3条回答
  •  旧时难觅i
    2020-12-16 22:11

    You need DBNull.Value rather than null when inserting into SQL server.

    When you set DateTime = null in .NET it takes the minimum value of DateTime which is 01-01-0001.

    I'd assume you are using a SMALLDATETIME in SQL Server where the minimum value is '01/01/1900'

提交回复
热议问题