开发者

ASP.net SQL server universal date problem

I need to solve the following problem for one of my clients. They have an installer which installs a SQL server database + IIS website.

The SQL database user can have any kind of date format (DD/MM/YYYY, MM/DD/YYYY,...) depending on the locale of the sql server. The IIS website can have any kind of date format (can be different from sql server). The user browsing to the website can have any kind of date format (date formats from all over the world).

I'm st开发者_Go百科ruggling to find a solution for the following: (asp.net) 1) an end-user using his browser must be able to enter and validate a date in it's own date format 2) the date must be written to the sql server in the date format of the sql server which can be different.

Hints are welcome.


For ASP.NET, I assume that you're using the Culture and UICulture to set date and time formatting to the user's preference. I haven't worked with ASP.NET's validator controls in a specific (non-US) culture, but I would be surprised if they don't honor the current culture as well.

The SQL Server answer is relatively easy: You have a .NET DateTime value in your code. Pass that to SQL Server as a parameter, rather than formatting it into an SQL statement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜