ADO.Net Convert Data\Time (MS Access) to OleDbType.Date

  • Thread starter Thread starter JHatfield
  • Start date Start date
J

JHatfield

I created a program using MS Access 2000 (Written in VBA,
2nd tier) that ties remote sites together and lets a user
view, and change settings using local network or VPN and
are saved to an .mdb file. (Which later this year will be
written in .Net). But for now we are creating the 3rd
tier, a web site using VS.Net to let our users view and
change their settings thought the web browser. The Problem
I have come upon is this. MS Access saves Date and Time
fields as Date/Time datatypes. When creating an
DataAdapter with Ado.net it uses oleDbType.Date not
oleDbType.TimeStamp. If I use OleDbType.date and use
(VB.Net) DateTime.Now, DateTime.Today or DateandTime.Now
it will drop the time and keep the date only. The same
will happen if I manual change OleDbType.Date to
OleDbType.TimeStamp. The only way to get the time after I
change it to OleDbType.TimeStamp is to pass
DateandTime.TimeOfDay. Well you may as long as I can get
the time saved, what does it matter. If for some reason I
have to run the DataAdapter wizard again, I will have to
change the entire settings manual again. And this project.
I will be rewriting the 2nd tier using .net. If I have to
Manual change each and every table that uses Data\Time for
a time field,each time I change something. This would be a
problem. The only way to get around this would to save
both date and time in the time field, and use only what I
need. But so far, if I am able to save both date and time
to the same field. one is incorrect (eg. 1\1\2001 and
correct time - using dateandtime.timeofday,or correct date
but incorrect time with other methods). If anyone knows a
way to get around, without having to manual change every
thing please let me know. Thanks JH
 
Back
Top