Database does not take time value

  • Thread starter Thread starter J M
  • Start date Start date
J

J M

Hi,

I have a huge problem in an app I'm writing.
I use an OleDbDataset (and OleDbDataTable, and so on, created in the
Component Designer) to add rows to a table.
Three of the columns have Date/Time values.
Column 1 is only a date (time: 0:00), no problem there.
Columns 2&3 are only time (I struggled to extract only the time from a Date,
who the hell came up with the idea of returning the TimeOfDay prop of a
DateTime as a TimeSpan instead of a Date??)

Here comes the problem: In my DataRow object, all data is correct (checked
in QuickWatch), but in my database, the time columns are set to January 1,
2001 0:00.
I tried (among lots of other things, to test if I was doing something wrong)
to pass the literal #5/10/2004 15:32# in one of the columns. in the database
it showed as 5/10/2004 0:00...

When reading dates from existing (that is, data that was already in the
database before, entered in Access), there seems to be no problem....



J Mous
 
Hi JM,

A well known item, there is no time value in a database.
So you would use a string or a datatime field where you know that you have
to cut of the date.

I hope this helps anyway?

Cor
 
But why then can it read values correctly, but not write them?
Is it a bug in the framework??

J Mous
 
Hi JM,

You can write them, however it will always be with the date 1900 01 01 (or
something)

Cor
 
I found out a way to do it. Thanks for your help!!!
I'll share it with you so if anyone encounters the same problem (quite
likely): This is the solution:

I changed the OleDbType for all date/time columns in the dataset designer to
'time' (instead of dateTime) and in all parameters of all commands that had
to do with the date/time values, I set OleDbType to "Date" instead of
"DBDate"... I don't know which of the two did te job (or both)...

J Mous

(I'm sorry for spelling mistakes. 1/ English is not my primary language. 2/
my H key seems to refuse to do anything most of the time...)
 
Back
Top