PDA

View Full Version : Bug: OLEDBProvider for MS-ACCESS DateTime ???


zhoullhh
03-29-2007, 03:35 AM
:( I am using Spring.NET to access MS Access database. One of the column in the table is "DateTime".

I added my Parameter by the following way,

parameters.Add("DtReceived", DbType.DateTime).Value =DtReceived;

However, when I looked at the new Parameter, it OldDbType shows as "DbTimeStamp", which is not correct since the field in database is a DateTime field, but the DbType is "DateTime" which is correct.

The "DbTimeStamp" cause the following
"Data type mismatch in criteria expression. (Microsoft JET Database Engine)".

I tried to replace DbType.DateTime by OleDbType.DateTime, it works fine without problem. However, I can not do that since I have to support SQL Server, Oracle as well.

I also tried to use DbType.Date, it worked, however, it truncates the time information which based on the name, should be correct.

I tried to dig into some of the code of Spring to see where the parameter type get assigned, but can not find too much help there.

Appreciate any help here!!!

zhoullhh
03-29-2007, 02:37 PM
Hmmmm, as I digged into the Spring code and found that Spring doesn't do the mapping here. It seems that the .NET type mapping. Here is the URL from MSDN.

http://msdn2.microsoft.com/en-us/library/bbw6zyha.aspx

it seems that I can not get what I want here if
by using System.Data.DbType, if the Date doesn't work. (right now, it truncate all of the time information for me.)