当web.config 里

<system.web>
    <globalization culture="en-GB" />

 

设置为英国

英国默认的日期格式为 dd/MM/yyyy

而一般美国,加拿大服务器的的默认区域为 “en-US” 可以用 SELECT @@LANGUAGE 查看当前区域

美国的日期格式默认为MM/dd/yyyy,服务器数据库就会把程序中的 dd/MM/yyyy 解读为 MM/dd/yyyy格式

就会出现类似

从 char 数据类型到 datetime 数据类型的转换导致 datetime 值越界。

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: 从 char 数据类型到 datetime 数据类型的转换导致 datetime 值越界。

这种错误

 

解决办法:

在数据库中新建用户,选择默认语言为:British English,使用这个用户就行了

 

相关文章:

  • 2021-05-26
  • 2021-11-10
  • 2021-11-23
  • 2021-12-17
  • 2022-12-23
  • 2022-01-01
  • 2021-07-01
猜你喜欢
  • 2021-08-06
  • 2021-07-07
  • 2021-07-04
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2021-12-27
相关资源
相似解决方案