简体   繁体   English

Windows 10 / IIS / Classic ASP上的Access 2016中的日期格式还原

[英]Date formatting reverting in Access 2016 on Windows 10/IIS/Classic ASP

hopefully I can explain this problem in enough detail for someone to let me know of a possible solution, or at least let me know there isn't a fix (other than the one I mention below). 希望我可以对某人足够详细地解释这个问题,以便让我知道一个可能的解决方案,或者至少让我知道没有解决的方法(除了我在下面提到的解决方法)。

Ok, I am migrating from the following environment: 好的,我正在从以下环境中迁移:

Windows XP/Access 2003/Classic ASP/IIS Windows XP / Access 2003 /经典ASP / IIS

to: 至:

Windows 10 Pro/Access 2016/Classic ASP/IIS Windows 10 Pro / Access 2016 /经典ASP / IIS

Basically I have a local website running in IIS written in Classic ASP. 基本上,我有一个以经典ASP编写的IIS中运行的本地网站。 The pages run in a web browser and there are plenty of inserts and updates occurring in an Access DB. 这些页面在Web浏览器中运行,并且Access DB中发生了大量插入和更新。 The Win XP environment is setup as located in Australia, however I have all formatting as US based, so that all formatting occurs in "mm/dd/yyyy". Win XP环境设置为位于澳大利亚,但是我所有的格式都基于美国,因此所有格式都以“ mm / dd / yyyy”表示。

In Windows XP, I can run a query update in ASP as follows treating the date as a string: 在Windows XP中,我可以按如下所示在ASP中运行查询更新:

    theDate = Now()
    SQLStmt =   "UPDATE tTable SET DateField ='" & theDate & "' WHERE DateID=1"

and it works just fine, as in if the date is October 1st 2017 it will appear in the Access DB table as 10/01/2017. 并可以正常工作,就像日期是2017年10月1日一样,它将在Access DB表中显示为10/01/2017。 The date type of the date field (in the above example, DateField) is of type "Date/Time". 日期字段的日期类型(在上面的示例中为DateField)的类型为“日期/时间”。

So, I installed Windows 10 Pro, setup IIS with Classic ASP, created a virtual directory, moved over all the files from Win XP, and went about changing all the date settings throughout Win 10 to be US format. 因此,我安装了Windows 10 Pro,使用Classic ASP设置IIS,创建了一个虚拟目录,从Win XP移至所有文件,然后将整个Win 10的所有日期设置更改为美国格式。 I have also changed the "Locale ID" under "Configure properties for ASP applications" to 1033 in IIS. 我还将IIS中“配置ASP应用程序的属性”下的“语言环境ID”更改为1033。 Access DB is being used without converting to Access 2016 (so it can be moved back to Win XP environment if need be). 使用Access DB时不会转换为Access 2016(因此可以根据需要将其移回到Win XP环境中)。

However, running the above query results in the date going into Access DB as "01/10/2017". 但是,运行上述查询会导致进入Access DB的日期为“ 01/10/2017”。

So I setup the following code to test out the date formatting: 因此,我设置了以下代码来测试日期格式:

    theDate_01 = Now()

    theDateTime = FormatDateTime(theDate_01,3)

    theDate_02 = Year(theDate_01)&"-"&Month(theDate_01)&"-"&Day(theDate_01)&" "&theDateTime

    SQLStmt =   "UPDATE tDateTest SET "
    SQLStmt =   SQLStmt & "theDate='" & theDate_01 & "'"
    SQLStmt =   SQLStmt & " WHERE DateID=1"
    Set RS = conntemp.execute(SQLStmt)

    SQLStmt =   "UPDATE tDateTest SET "
    SQLStmt =   SQLStmt & "theDate='" & theDate_02 & "'"
    SQLStmt =   SQLStmt & " WHERE DateID=2"     
    Set RS = conntemp.execute(SQLStmt)

%> %>

Basically I have a table called tDateTest in Access, with two columns DateID and theDate. 基本上,我在Access中有一个名为tDateTest的表,其中有两列DateID和theDate。

The result from running the above code is that theDate_01 is inserted incorrectly (that is, in AU date format) whilst theDate_02, because I've turned it first into yyyy-mm-dd format, does get inserted correctly. 运行上面的代码的结果是,正确插入了theDate_01(即以AU日期格式),而由于我首先将其转换为yyyy-mm-dd格式,因此theDate_02确实被正确插入。

Now with hindsight I would have done this whenever I was updating/inserting a date, however I am in the situation where I have many pages of code with many date updates/inserts that would need to be changed. 现在事后看来,无论何时我要更新/插入日期,我都会这样做,但是我处在很多页面的代码需要更改许多日期/插入的情况下。

Is there any way to have the environment in Windows 10 behave the way it has been in Win XP, that a query with a date string simply inserts/update into an Access date/time field in the format I've specified throughout Win 10/IIS, in US format? 是否有任何方法可以使Windows 10中的环境像Win XP中那样运行,即带有日期字符串的查询只是以我在Win 10 /中指定的格式简单地将其插入/更新到访问日期/时间字段中, IIS,采用美国格式?

First, you might be able to simply do: 首先,您可以简单地执行以下操作:

SQLStmt = "UPDATE tTable SET DateField = Now() WHERE DateID=1"

If not, force the format and use octothorpes: 如果不是,请强制使用格式并使用八叉索:

SQLStmt = "UPDATE tTable SET DateField = #" & Format(theDate, "yyyy\/mm\/dd") & "# WHERE DateID=1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 经典ASP,IIS6和IIS8之间的DATE区别 - Classic ASP, DATE difference between IIS6 and IIS8 IIS 7,Microsoft Access和Classic ASP的最高效的ADODB连接 - Most efficient ADODB connection for IIS 7, Microsoft Access and Classic ASP 在 Windows server 2008 R2 64bit & IIS7.5 上运行经典的 asp & ms access 2000 - Running classic asp & ms access 2000 on Windows server 2008 R2 64bit & IIS7.5 在Windows 10下访问2016年相当大的窗体边界太窄 - Access 2016 sizable form borders too narrow under Windows 10 c# 无法打开数据库 - Windows 10 Access 2016 - c# Cannot open Database - Windows 10 Access 2016 经典的ASP访问数据库在Windows Server 2012上不起作用 - classic asp access DB not working on windows server 2012 Server2008R2上的经典ASP + MS Access(IIS 7) - 读取但无法写入 - Classic ASP + MS Access on Server2008R2 (IIS 7) - read but can't write 运行IIS 7的Windows 2008 Server上的ASP Access Database网站 - ASP Access Database web site on Windows 2008 Server running IIS 7 请问我知道什么错误 Microsoft JET 数据库引擎错误 '80040e10 在经典 ASP 与 ms 访问 - Please may I know what error Microsoft JET Database Engine error '80040e10 in classic ASP with ms access 带有MS Access DELETE的经典ASP循环失败 - Classic ASP with MS Access DELETE fails in loop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM