Returned values from web service is wrong

  • Thread starter Thread starter Jimmy
  • Start date Start date
J

Jimmy

Hey

Im calling a webservice wich is returning a DataSet. In the DataSet, wich is
generated from a SQL query, there is a date field. This datefield (datetime)
has the value '12-04-2004' (Danish date format, or actually i think it
stores it as italian in the database. Corresponds to DD-MM-YYYY).

If i try to write the returned DataSets values out, in my program from the
returned DataSet it keeps writing '11-04-2004 15:00:00'. What is that?

Anyone who can explain to me what happens?

Ive tried to see wether the value that is written is right, in the xml
document that returns from the web service. The value looks like this:
<dato>2004-04-18T00:00:00.0000000+02:00</dato>

So i presume that the returned value is correct, but it is apparently wrong
in the dataset on the client side, or it is converted to the day before
during writing out the value.

label1.Text = DataSet.Tables[0].Rows[0]["dato"].toString();

label1.Text is now '11-04-2004 15:00:00' even though the value in the
returning xml document says the 12. April 2004

It happens with all of my dates. They are all set to the previous day at
1500 hours

How can i solve my problem?
Anyone knows anything about this?

Please help....
 
Hi,

The following article gives an overview over DateTime related issues:
http://msdn.microsoft.com/netframew.../library/en-us/dndotnet/html/datetimecode.asp

Extract from the article:

"When using the .NET Framework version 1.0 and 1.1, DO NOT send a DateTime
value that represents UCT time thru System.XML.Serialization. This goes for
Date, Time and DateTime values. For Web services and other forms of
serialization to XML involving System.DateTime, always make sure that the
value in the DateTime value represents current machine local time. The
serializer will properly decode an XML Schema-defined DateTime value that is
encoded in GMT (offset value = 0), but it will decode it to the local
machine time viewpoint."


The DateTime is also a struct, not a class, so it might give weird results
depending on how you use it.

Chris
 
Christopher Kimbell said:
Hi,

The following article gives an overview over DateTime related issues:
http://msdn.microsoft.com/netframew.../library/en-us/dndotnet/html/datetimecode.asp

Extract from the article:

"When using the .NET Framework version 1.0 and 1.1, DO NOT send a DateTime
value that represents UCT time thru System.XML.Serialization. This goes for
Date, Time and DateTime values. For Web services and other forms of
serialization to XML involving System.DateTime, always make sure that the
value in the DateTime value represents current machine local time. The
serializer will properly decode an XML Schema-defined DateTime value that is
encoded in GMT (offset value = 0), but it will decode it to the local
machine time viewpoint."

This is the problem. It gives me the time i select from my database in UTC
time plus or minus my local time (+02:00). At the client side i guess it
just interprets the time and write it out. Therefore the difference in time.
Im a little confused about the actual timespan, but definetely, this is the
problem.

Thanks...
 
Back
Top