Dataset won't store milliseconds.

Heiko

Well-known member
Joined
Feb 10, 2003
Messages
430
Location
Holstein, Germany.
I am having problem with this fragment of code:

Code:
 Public Sub SaveDatabaseValue(ByRef myRow As System.Data.DataRow, ByVal columnName As String) Implements IExtendedControl.SaveDatabaseValue
        Dim dt As DateTime

 ... snip

dt = CType(txtDate.Text & " " & txtTime.Text, DateTime)

If mIsEstimatedValue Then
   dt.AddMilliseconds(5000)
End If

myRow(columnName) = dt
End Sub

because my row will not contain the milliseconds value.
All I get is seconds.

(datarow is a row from a table from a strongly typed dataset).

Code:
<xs:element name="PZE_IstDatumUhrzeitVon" codegen:nullValue="9999-01-01T00:00:00" type="xs:dateTime" minOccurs="0" />

This is generated.

Any ideas how I can convince my dataset to accept milliseconds?
 
A DateTime stores the milliseconds and so does SQL Server. My guess is that the line that first sets dt doesnt store milliseconds (just the date and time). Later you add 5000 milliseconds, which is just 5 seconds. Your milliseconds should still be 0, as expected.

Try your test setting dt to DateTime.Now to see if the code works. Make sure that the value DateTime.Now HAS milliseconds as well as you may get lucky/unlucky and hit it just right :)

-Nerseus
 
Thanks Nerseus,
Yep. You pointed out one embarrassing mistake ... 5000 ms is 5 seconds. Bummer :) I changed it to 500 and still ist doesnt work.
(just for my reputation, I discovered that before reading your reply :) )


When using the datasets .toXML method, I can see the seconds and milliseconds (or ticks to be precise) in the XML file.

Surprisingly, this does work with seconds (txtTime.Text is hh:mm).


In short:
When I look at the datarow.item (.toString) I never see the milliseconds. All I see is seconds. When I look at the XML file with the datarow in it, I see the ticks all set to zero.
 
Back
Top