c# - 日期中的月份无效 - Informix 中的日期格式偶尔会恢复

标签 c# asp.net windows informix aix

所以我们有一个运行 ERP 系统的 AIX(呃)服务器。这个系统的内置报告很糟糕,所以我当然要负责构建我们需要的报告。

我运行了很多报告,当然大部分都是针对特定日期等的。编码是在 Windows 2003 Standard Server 机器上的 ASP.net 中运行的 C# 中完成的。它使用 Informix CSDK 通过 CSDK 附带的 .Net 数据适配器进行连接。服务器在 AIX 5.2 服务器上运行 Informix 10。

奇怪的是,每当我们启动和停止 Informix 或重新启动服务器等时,Informix 似乎决定更改它通过 CSDK 处理日期的方式。如果它当前期望 MM/DD/YYYY 那么它最终会在上述情况之后决定在 YYYY/MM/DD 中​​需要它。这通常会给我一个“日期中的无效月份”错误。然后我进入我的 dateformat 函数(使我可以轻松地来回切换)并手动更改它。我在处理此错误时构建了一些报告,然后使用其他格式的日期重试相同的查询。这当然不太理想,我想查个水落石出!

这是一些来自 ASP.net 页面错误的粘贴文本。谢谢!

Server Error in '/' Application.
ERROR [HY000] [Informix .NET provider][Informix]Invalid month in date
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details: IBM.Data.Informix.IfxException: ERROR [HY000] [Informix .NET provider][Informix]Invalid month in date

Source Error:

Line 479:
Line 480:        //aUsage = new IfxDataAdapter(sSelect_Usage, conn);
Line 481:        aUsage.Fill(dsUsage, "Usage");
Line 482:        aUsage.Dispose();
Line 483:        dtUsage = dsUsage.Tables["Usage"];


Source File: D:\Inetpub\reports2.oscarwinski.com\App_Code\IMRShipClass.cs    Line: 481

Stack Trace:

[IfxException: ERROR [HY000] [Informix .NET provider][Informix]Invalid month in date]
   IBM.Data.Informix.IfxConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) +26
   IBM.Data.Informix.IfxCommand.ExecuteReaderObject(CommandBehavior behavior, String method) +654
   IBM.Data.Informix.IfxCommand.ExecuteReader(CommandBehavior behavior) +117
   IBM.Data.Informix.IfxCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +4
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
   IMRShipClass.Generate() in D:\Inetpub\reports2.oscarwinski.com\App_Code\IMRShipClass.cs:481
   IMRShip.testIMR() in D:\Inetpub\reports2.oscarwinski.com\IMRShip.aspx.cs:114
   IMRShip.btnExport2Excel_Click1(Object sender, EventArgs e) in D:\Inetpub\reports2.oscarwinski.com\IMRShip.aspx.cs:259
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082 

最佳答案

日期格式由客户端控制,而不是服务器。显然它有一个默认值(美国格式),但每个客户都可以指定它希望使用的格式。这是通过设置 DBDATE environment variable 来完成的。 . (如果您使用的是语言环境,还有 GL_DATE。)

如果日期格式发生了变化,你应该检查这个环境变量的值。在某些情况下它是由您的中间件设置的吗?

关于c# - 日期中的月份无效 - Informix 中的日期格式偶尔会恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1208377/

相关文章:

c# - 如何检测 .Net 中的装箱原因?

windows - 以编程方式禁用快速启动(系统设置)

c# - DateTimeOffset,理解不清楚

c# - 字符串插值 C# : Documentation of colon and semicolon functionality

asp.net - vb.net 单选按钮列表检查是否被选中

javascript - 如何在 JavaScript 中使用内联 ASP.NET 标记?

css - IE9 无法通过 SSL 加载 CSS

c++ - 如何在 Windows 上的 cuda 推力调用中指定 OpenMP 执行策略?

java - 在 Windows 7 Pro 中使用批处理文件关闭多个 cmd 窗口。

c# - WPF 学习曲线有多糟糕?