Date Parameter - System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

rito1
rito1 used Ask the Experts™
on
Hi All,

I am working on an ASP.NET website which uses MS Access as a database.

I am trying to pass a date parameter into an Access query but get the following error when executing the OleDbCommand:

System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.

I have double checked that my parameter is formatted as a date using the DateTime data type within ASP.NET.

Is there something else I should know about MS Access date formats which could be causing this issue?

Thanks,

Rit
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ǩa̹̼͍̓̂ͪͤͭ̓u͈̳̟͕̬ͩ͂̌͌̾̀ͪf̭̤͉̅̋͛͂̓͛̈m̩̘̱̃e͙̳͊̑̂ͦ̌ͯ̚d͋̋ͧ̑ͯ͛̉Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:
Can you post how you are inserting the date value into the query?
Consultant Software Engineer - .NET Architect
Commented:
Hi,
If you are passing date as string to Access you pass date as #datevaleu#

or followthe link for more details:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/f5957ece-0535-447d-9b2a-7df5c5e8fb08/

Thanks
nekkantisurendraSoftware Engineer
Commented:
Hi, Check if the below formatting helps.

http://www.techonthenet.com/access/functions/date/format.php

Author

Commented:
I got sorted... I needed to use the DateTime.ToOADate Method for MNS Access.

thanks,

Rich

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial