R
Roy Soltoff
Using Framework 3.5: I've converted a data base access project that was
written against the OleDbProvider to now be provider independent using a
DbProviderFactory. In doing so, I had to migrate my update and insert
commands from OleDbCommand to DbCommand created using the factory. This
meant that I changed the Parameter items to use DbType rather than
OleDbType.
The program uses a Vb Date type that is equivalent to a System.DateTime. I
previously the OleDbType.Date type for updating date columns; the database
is an Access Jet 4.0 database. So I used the DbType.DateTime type in the
provider independent code. This updates the database date columns okay only
when the date/time value is no more precise than minutes (i.e. #4/15/2009
11:45:00 AM#). If the date/time value has a precision of seconds (i.e.
#4/15/2009 11:45:25 AM#), the update fails with a "Data type mismatch in
criteria expression" error. It acts as if the mapping of DbType.DateTime
does not have the precision needed for the database date column where, in
fact, the OleDbProvider using OleDbType.Date was fine. There is a
DbType.DateTime2 that appears to reflect the same precision of a System.Date
however that type has no mapping to the OldeDbType (that was the error
message).
Does anyone know if there is a bug in the framework's conversion of
DbType.DateTime to the OleDb provider?
written against the OleDbProvider to now be provider independent using a
DbProviderFactory. In doing so, I had to migrate my update and insert
commands from OleDbCommand to DbCommand created using the factory. This
meant that I changed the Parameter items to use DbType rather than
OleDbType.
The program uses a Vb Date type that is equivalent to a System.DateTime. I
previously the OleDbType.Date type for updating date columns; the database
is an Access Jet 4.0 database. So I used the DbType.DateTime type in the
provider independent code. This updates the database date columns okay only
when the date/time value is no more precise than minutes (i.e. #4/15/2009
11:45:00 AM#). If the date/time value has a precision of seconds (i.e.
#4/15/2009 11:45:25 AM#), the update fails with a "Data type mismatch in
criteria expression" error. It acts as if the mapping of DbType.DateTime
does not have the precision needed for the database date column where, in
fact, the OleDbProvider using OleDbType.Date was fine. There is a
DbType.DateTime2 that appears to reflect the same precision of a System.Date
however that type has no mapping to the OldeDbType (that was the error
message).
Does anyone know if there is a bug in the framework's conversion of
DbType.DateTime to the OleDb provider?