DateTime Frustration...

  • Thread starter Thread starter Roy Eyman
  • Start date Start date
R

Roy Eyman

I am developing a .NET application in C# that uses an
Access database via oledb. I have created the Access
database in Access design view, created a DataTime column
with no formatting or input mask.

In my C# application I am setting this field to the
current datetime using DateTime.Now. No errors are
reported, but when I go back and open the database and
look at the datetime field, all that is there is the date,
the time is not included. I've tried all the formatting
methods in C#, such as DateTime.Now.ToLongDateString(),
etc., but nothing makes any difference; I always get the
date, but not the time.

What am I doing wrong?

Thanks,
Roy.
 
I found it, I built the C# dataAdapter object with the
Visual Studio designer and it defaults DateTime fields
from Access tables to type "DBDate" in it's autogenerated
code. Once I found this I simply changed the datatype in
the autogenerated code to DBTimeStamp and everything works
fine now.

Thanks,
Roy
 
Back
Top