2

我正在尝试使用 win2k8 将旧的经典 asp 应用程序迁移到 IIS 7.0,如果我能提供帮助,我肯定不想更改旧代码。

我在控制面板的区域和语言选项中的日期格式和语言选项中的自定义区域选项中设置了日期格式为 dd-MMM-yy。

即使在重新启动后,我仍然使用此日期格式收到 Conversion_failed_when_converting_datetime_from_character_string 错误。

我也在使用 SQL Server Express 2005。

您还需要在哪里设置日期格式?它们都应该从机器设置中提取吗?

旧代码做了一些非常愚蠢的事情,但我不想再次更改它然后再次测试它。

旧代码有效地执行此“插入MyTable(ThisDate)值('”&Now()&“')”

生成插入 MyTable (ThisDate) 值('17/03/2009 3:40:48 pm')

消息 241,级别 16,状态 1,第 1 行从字符串转换日期时间时转换失败。

它实际上抱怨的是字符串的“pm”部分,尽管机器上的区域设置指定不使用它。

4

3 回答 3

5

This is a very annoying problem which comes from installing Server 2008 with a different region setting to what you ultimately want to use.

Typically this problem arises where the Server is set to USA and the user then subsequently sets the location to UK. Then when the code is executed it returns 1/17/2012 instead of 17/1/2012 and yes SQL Server may return errors like "Conversion_failed_when_converting_datetime_from_character_string".

The problem is that the IUSR account has its own region setting and it's this setting that the server uses when executing classic ASP. This is what you have to do to fix it...

Open the Region and Language options from the Control Panel. You should see the "Administrative" tab, click on Copy Settings. Make sure that the settings listed under 'Current User' are those that you want replicated, if they're not then backtrack to the keyboard layout etc and set them. Tick the box 'Welcome screen and system accounts' and then OK. Reboot.

Now it should work.

于 2012-01-17T10:30:30.663 回答
1

对于任何关注区域设置的应用程序,您只需设置一个位置,并且您已经在那里设置了它。

Conversion_failed_when_converting_datetime_from_character_string”是什么来的?VB脚本?也许它不注意区域设置。

于 2009-03-17T01:02:07.013 回答
1

您所要做的就是将 .Net 全球化部分中的文化设置更改为您所在的国家/地区,它应该可以解决它。

于 2011-01-20T20:38:09.133 回答