DataTable DateTime列格式错误 [英] DataTable DateTime column format error

查看:109
本文介绍了DataTable DateTime列格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的生产系统中有1个突然出现了以下错误.这是在IIS下托管的Web服务中发生的.

We started having the following error out of sudden in 1 of our Production system. This happened in a Web Service hosted under IIS.

字符串未被识别为有效的DateTime.无法存储< 11/19/2016 23:44:22>在CMISUpdatedTime列中.  预期的类型是DateTime.

  • 该系统的设置与具有相同IIS和系统设置的另一个系统相同.
  • Windows区域格式设置为en-US,IIS区域性设置设置为默认值.
  • 相同的应用程序已部署到两个系统中,并且直到今天早上开始出现此错误为止,该应用程序都没有出现任何问题.
  • This system was set up identical to another system with the same IIS and System Settings.
  • The windows Regional format was set to en-US and the IIS culture settings were set to the defaults.
  • The same application was deployed to both systems and the application was running without any issues until this morning where this error started occurring.

下面是发生此错误的代码:

Below is the code where this error is occuring :

patientDataset.Tables["P_MED_GetPatientHeaderInfo"].Rows[0]["CMISUpdatedTime"] = strSplitParams[3];

此代码一直有效,直到今天凌晨3:11才开始出现错误.该方法的最后一次成功命中时间是凌晨2:11,没有任何问题.相同的代码也可以在相同的系统中运行,而不会出现任何问题.

This code was working without any issues until this morning 3:11 am where the error started appearing. The last successful hit of this method which was at 2:11 am didn't have any issues. The same code is also running in an identical system without any issues.

到目前为止,我们已经进行了以下调查:

So far, we have investigated and done the below :

  1. 检查系统或IIS设置是否有任何更改(未找到更改)
  2. 检查事件日志,发现应用程序池在凌晨2:16重新启动(不确定是否会引起任何问题?)
  3. 重新启动IIS(错误仍然存​​在)

我们目前正在探索以下选项:

We are currently exploring the following options :

  1. 手动回收应用程序池
  2. 在IIS设置中将此应用程序的区域性设置为en-US

以上选项需要系统管理员的权限.因此,我们需要提供证据证明这样做是否可以解决问题.

The above options require permissions from the System Admin. So, we need to provide evidence whether the issue will be solved by doing them.

我们目前的构想已用完.对于这种情况有什么建议吗?

We are currently running out of ideas. Any suggestions for this scenario?

推荐答案

Dinesh,

Hi Dinesh,

您的文化以某种方式从"en-US"发生了变化.我已将"en-US"设置为"en-US",因此,如果我拿起您的日期字符串并交换它,以便它变为"19/11/2016 23:44:22", (对于"en-US"显然无效),然后我得到 同样的错误.

Somehow your culture has been changed from "en-US". I'm set up with "en-US", so if I take your date string and swap it around so that it becomes "19/11/2016 23:44:22" (obviously invalid for "en-US"), then I get the same error that you got.

因此,我认为您的想法是将IIS设置中此应用程序的区域性设置为en-US".应该可以解决您的问题.

So, I think your idea to "Set the Culture for this Application in IIS Settings to en-US" should solve your problem.


这篇关于DataTable DateTime列格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆