Time is Stripped off When Saving DateTime to MS Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

All,

Using C# with ADO.NET I am trying to save a date time to an Access database.
After the saving occurs I open Access database and only see the date not the
time.
I know the time was part of the DateTime object prior to saving it. Also
while in Access I tried changing the format of the date time field to see the
time, which showed it as 12:00 AM and is incorrect.
See code snippet below:
DataRow newRow = dataSet12.Table1.NewRow();
newRow["Index"] = 5;
newRow["Column1"] = "Added";
newRow["MyDateTime"] = DateTime.Now; // <== Time is in object
dataSet12.Table1.Rows.Add(newRow);
Does anyone know who to have the time saved ad well?

Thanks in advance for any help.
Scott
 
=?Utf-8?B?U2NvdHQ=?= said:
Using C# with ADO.NET I am trying to save a date time to an Access
database. After the saving occurs I open Access database and only see
the date not the time.

What is the exact field type as declared in Access?
 
Note to everyone: The solution to resolve this was to set the DateTime type
in the command objects (I.E. oleDbInsertCommand2) from OleDbType.DBDate to
OleDbType.DBTimeStamp.
Doing this now generates both a date and time in an Access database.
 
Back
Top