Click here to Skip to main content
15,888,088 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

Member 2068169 wrote:
the date field throws error


How is anyone expected to guess what the error is?
 
Share this answer
 
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?

Edit: See Luc Pattyn's answer. It is better.
 
Share this answer
 
v2
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.

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900