荷兰日期格式 [英] dutch date format
问题描述
我正在为使用sqlserver 2008数据库的荷兰客户端开发ASP.net c#项目.
数据库服务器具有本地荷兰语设置.
当我尝试使用与荷兰数据库服务器连接的开发服务器将日期插入表中的日期字段之一时,将插入记录.
但是,如果我将站点托管到生产服务器中并使用生产服务器的数据库,则日期字段会引发错误
请帮助
在此先感谢
Hi,
I am working on a ASP.net c# project for Dutch client that uses sqlserver 2008 database.
The database server is having local Dutch settings.
When i try to insert the date into one of the date fields in a table using my development server with connection to dutch database server, the record gets inserted.
But if i host the site into the production server and use the database of production server, the date field throws error
Pls help
thanks in advance
推荐答案
日期字段引发错误
the date field throws error
How is anyone expected to guess what the error is?
想必,人们之间如何猜测错误的出处?大概是机器之间的语言环境设置有所不同.听起来您已经在考虑这一点.那么,您是否检查了涉及的每台计算机上使用哪种日期/时间格式的设置?
请参阅Luc Pattyn的答案.最好.
Presumably, there is a difference in locale settings between the machines. It sounds like you are already thinking about this. So have you checked the settings for what date/time format is used on each of the machines involved?
See Luc Pattyn''s answer. It is better.
可以通过三个步骤来避免此类问题:
1.
您的数据库应使用适当的字段数据类型存储日期和日期/时间,而不应将其存储为字符串;如果您使用的数据库类型不正确,则应该切换到另一个数据库,或者使用具有固定日期时间格式的字符串(适用于ISO 8601的Google).
2.
您的数据库操作应参数化;不要使用日期文字(必须包含格式约定),而应使用SqlParameters(或适用于您数据库的任何内容).
3.
每当用户必须将日期输入为字符串(您是否考虑使用DateTimePicker吗?)或应用必须输出文本日期时,您的应用便应使用日期格式.
在大多数情况下,体面的事情是应用机器的区域设置,因为这是用户做出的选择.
:)
There are three steps to avoid such problems:
1.
your datebase should store dates and date/times using the appropriate field data type, and NOT as strings; if the database you use doesn''t have an appropriate type, you should either switch to another database, or use strings with a fixed datetime format (Google for ISO 8601).
2.
your database operations should be parameterized; don''t use date literals (which are bound to include a formatting convention), use SqlParameters instead (or whatever applies to your database).
3.
Your app should take care of date formatting anytime your user has to input a date as a string (did you consider using a DateTimePicker?) or your app has to output a textual date.
In most situations, the decent thing to do is to apply the machine''s regional settings, as that is the choice the user has made.
:)
这篇关于荷兰日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!