views:

782

answers:

3

Can someone plz tell me what's the Use of DataSet.Locale and can it be used to solve this issue.

My Server is located in US and I am running a query against it. The Data contained in the table both at Remote Server(U.S) and Local are same.

The Problem is when I am retrieving the DataSet using WebService from Remote Server. The Dates Column is showing The Previous Date. For e.g Date Column is having "14 Jan 2007" but when retrieved its Showing "13 Jan 2007".

I am not able to identify the cause as every other thing is working fine.

A: 

The property is used to determine the locale a dataset will use when the strings in it are compared.

For more information see the MSDN reference page here.

EDIT: Just in reference to your problem: Where is the 'local' machine? You aren't per chance crossing the date line to the server?

Nick
Local Machine is in India
Ok, if you are querying first thing in the morning in India, a West Coast based server in the US won't have gone past midnight yet.Is the problem reproducible at all times of day?
Nick
Not all Times of Day but It happens specially in the Morning as you have mentioned
I think the most likely explanation then is that at certain parts of day (in the morning for Indian time zone), the server in the US has not transitioned to the same date yet. I would suggest testing this at regular intervals during the day, and determining if there is a specific 'cut off' time.
Nick
Thanks for the suggestion
A: 

Sounds like a known TimeZone issue: changing DataSet.Locale won't help.

Look at the following KB article for more info: http://support.microsoft.com/kb/842545.

Also look at the DataColumn.DateTimeMode property, which controls the serialization format of a DateTime column. Setting it to DataSetDateTime.Unspecified ensures no offset is added when serializing.

Joe
I have seen that KB. The thing is the product is quite Old built on 2003 version 1.1. We dont' have access to WebService Code. The pity is the returned dataset contains the modified dates. Using DataSet.GetXML gives the offset value which shows the Clients TimeZOne.
+1  A: 

You're likely seeing the issue if the time portion of the DateTime type is 12:00:00. If that value (14 Jan 2007 12:00 AM) gets submitted in EST, then it'll be offset as you move through western timezones (i.e. 13 Jan 2007 11:00 PM in CST)

The best way around this is to make sure you store DateTime data in an invariant type (convert it to UTC pr GMT). Then, when you get to whichever consumer needs the data, they can change the data into the locale-specific representation. If you're not able to control how the data is saved, then just make sure you convert it to an invariant type as you retrieve, before you return it to a client.

The link @Joe referenced is useful, otherwise here's a fairly large whitepaper detailing best practices regarding the issue.

http://msdn.microsoft.com/en-us/library/ms973825.aspx

Here's a stack overflow Q'n'A regarding some of the newer technologies, also.

http://stackoverflow.com/questions/65164/best-practices-for-datetime-serialization-in-net-framework-3-5-sql-server-2008

Note: there's an interesting point in that first link I added about serialization of some of these date types, depending on whether you're still on the 1.1/2.0 stacks. Pay attention to that as it's bitten me a couple times ;-)

joshua.ewer