Incorrect Time in DateTime column with MS Access database
-
I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)
-
I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)
-
Please check your data insertion code you might be inserting only date not time.Ms-Access is showing it's default behaviour when you are trying to access date wiche is actually not present in the column or what it has inserted by it's own
The DataSet and INSERT statement where both created by the designer using a DateTime type for the column in code. The database is set to for Date/Time datatype. Even when I have tried to update it manually using SQL and oledb commands, the resulting query returns the same... Correct date, 12:00:00 AM time. There is a workaround somewhere, I've used it a few years back, but not recently enough to remeber what it was. In the mean time, I changed the field datatype in the database to Numeric - Double. In my code I add a column at runtime and convert the OADate (Double) to a .NET DateTime type and disply the DateTime.ToShortDateString in generated column, then map that to my ComboBox DisplayMember property. It works, but shouldn't be that way. Thanks for the help
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)
-
I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)
Problem solved. Solution: Change all DataAdapter DateTime columns Input and Update parameters OleDbType to DBTimeStamp. By default the designer sets any Date/Time column to DBDate which only formats the data to store the date. This goes for DataAdapters created by the designer and for manually coded OleDbParameters.
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)