Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am having problem with this fragment of 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).

 

<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?

.nerd
  • *Experts*
Posted

A DateTime stores the milliseconds and so does SQL Server. My guess is that the line that first sets dt doesn't 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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Thanks Nerseus,

Yep. You pointed out one embarrassing mistake ... 5000 ms is 5 seconds. Bummer :) I changed it to 500 and still ist doesn't work.

(just for my reputation, I discovered that before reading your reply :) )

 

 

When using the dataset's .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.

.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...