ADO.NET Secret of eternal youth

  • Thread starter Thread starter Haim
  • Start date Start date
H

Haim

I have a web service which is syncronizing two Access (mdb) databases.

The web service accepts a dataset. Adds the data to a table on the
server and then returns the dataset with the server's id fields to the
client, and the client is updated.

Pseudo code as follows:
Webservice
Public function updateserver(inDS as dataset) as outDS as dataset
' all rows in inDS are in datarowstate.Added
myDataAdaptor.update(indS)

outDS = Routine with fills dataset and modifies a field to give all rows
datarowstate.modified
Return outDS

End function

This works fine when the server is my local machine. But when I deploy
the service to a remote webserver, A date field looses one day. i.e. a
field with the data March 12, 2004 is inserted to the Server's table as
March 11, 2004. The error occurs with the myDataAdaptor.update. there
is nothing wrong with the SQL as it works on the local machine and is a
very simple insert statement.

If I return the dataset without requerying the server, the dates return
unchanged.

There might be a European, US date problem, as the client is using
European dates and the server is somewhere in US (I assume), but I would
expect the dates to be completely destroyed instead of consistantly
loosing 1 day on update.

This is driving me crazy.

Haim
 
Hi Haim

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that the date value was loosing 1 day when
inserted by the web service on remote machine. If there is any
misunderstanding, please feel free to let me know.

Generally, this might be caused by a different date/time setting or locale
setting on the client and server machines. Could you please check if the
clock has the same date on bothe computers? When inserting the data to the
database table, are you passing the date values directly or have you done
something on it with paticular functions on the server?

HTH. If the problem still peresists, could you please show me your update
code and the whole insert command for the web service? It will be much more
efficient for us to do deliver our assistance with the code. Thanks for
your cooperation!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Kevin,

Thank you very much for your prompt reply. The host is a public host so
I'm not sure what their settings are. I'll write their support and see
if I can get some information. When they answer I'll pass the info on
to you.

The code on the server side is very simple. I'm using the update method
of an OLEDataadaptor.

The insert statement is Insert into Tempgames ( id, gamedate,
hometeam, visitingteam ) values
(?,?,?,?)

Haim
 
Haim,

<% Page language="vb %>
<% Response.Write(Now.ToString()) %>

Surely that would tell you the time on the host? A simple comparison with
your local time would tell you whether the settings are different.

Regards,
Anthony Williams
 
Hi Hami,

A quick way to test whether time difference is an issue would be to use
"noon" values (i.e. 12:00 instead of midnight) in the DateTime fields.
US is within 6-10 hours from Europe and this should therefore allow you
to test whether the time difference has an effect.

Yours,
Morten
 
Thanks to all for the help.&nbsp; There is a 10 hour difference between the servers, but why should this matter anyway?.&nbsp; I am passing the date as a value in the dataset not as a function.&nbsp; Someone suggested it might be a leap year problem where one machine doesn't recognize that its leap year.&nbsp;

How are the dates serialized in the dataset, when passed to the webservice.&nbsp; Are they strings or as a number like in excell.

Haim




Anthony Williams wrote:


Haim, &lt;% Page language="vb %&gt; &lt;% Response.Write(Now.ToString()) %&gt; Surely that would tell you the time on the host? A simple comparison with your local time would tell you whether the settings are different. Regards, Anthony Williams "Haim" &lt;[email protected]&gt; wrote in message news:[email protected]...



Kevin, Thank you very much for your prompt reply. The host is a public host so I'm not sure what their settings are. I'll write their support and see if I can get some information. When they answer I'll pass the info on to you. The code on the server side is very simple. I'm using the update method of an OLEDataadaptor. The insert statement is Insert into Tempgames ( id, gamedate, hometeam, visitingteam ) values (?,?,?,?) Haim Kevin Yu [MSFT] wrote:



Hi Haim First of all, I would like to confirm my understanding of your issue. From your description, I understand that the date value was loosing 1 day when inserted by the web service on remote machine. If there is any misunderstanding, please feel free to let me know. Generally, this might be caused by a different date/time setting or locale setting on the client and server machines. Could you please check if the clock has the same date on bothe computers? When inserting the data to the database table, are you passing the date values directly or have you done something on it with paticular functions on the server? HTH. If the problem still peresists, could you please show me your update code and the whole insert command for the web service? It will be much more efficient for us to do deliver our assistance with the code. Thanks for your cooperation! Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."Morten Mertner wrote: Hi Hami, A quick way to test whether time difference is an issue would be to use "noon" values (i.e. 12:00 instead of midnight) in the DateTime fields. US is within 6-10 hours from Europe and this should therefore allow you to test whether the time difference has an effect. Yours, Morten
 
Hi Haim,

The DataSet is serialized to an xml stream. In a datetime column, not only
time information, but also time zone is serialized. The following is an
example for an order date.

<OrderDate>1996-07-04T00:00:00.0000000+08:00</OrderDate>

+8:00 refers to time zone info. Web service use this information to convert
time to local value when deserializing. So I think the issue might have
something to do with the time setting and locale settings. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Thank you Kevin that apparently is the problem. How do I get around
it? In the mean time I add 1 day prior to saving on the date.
It appears to me that I'm losing that information when the dataset is
returned. i.e. if I have a time on the date string I'm sending, I'm
getting the date back with no time on it.

What is the easiest way to see the serialized data? Does writexml give
me the entire string you presented below.
I appreciate your assistance.
 
Hi Haim,

To workaround this, we have to give the same locale setting to client
machine as the server. Or the server will convert date and time to the
local setting. However, I think you needn't worry about this. Althought the
datetime information saved in database is according to the server locale
setting, when sending back to the client, it will be converted according to
client setting again.

To see the serialize data for a DataSet object, just call DataSet.WriteXml
to export the Xml to a file. for more information, please check the
following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemDataDataSetClassWriteXmlTopic.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Kevin,

Thanks for sticking with me on this. The dataset apparently goes out
with all the full information, but it comes back with only the date.
Even time data is lost comming fromt he server to the client. This
appears to be happening only on the deployed machine and not on my local
machine. Give me another day or two to do some experiments on it.

haim
 
Kevin,

Thanks again for all your help. What appears to be happening is
strange. I am sending a string like this:

<OrderDate>1996-07-04T19:00.0000000+03:00</OrderDate>
The field is saved to the access db on the server on the US west coast where it looses a day and when I get it back its like this:
<OrderDate>1996-07-03T00:00.0000000+03:00</OrderDate>
It does not save the time and the +03:00 remains, in spite of the fact that the date was changed to GMT - 7.

Haim
 
Hi Haim,

Since the time information is not saved to database, I think there might be
something wrong with the code of web service. Please check if the
parameters and their types of the insert and update command has been set
properly. The type has to be SqlDbType.DateTime and the size is 8.
Incorrect settings for these might truncate the time information.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top