Datatype mismatch errors in Access parameterized Date query (175258)
The information in this article applies to:
- Microsoft Visual InterDev 1.0
This article was previously published under Q175258 SYMPTOMS
When using the Query Designer to execute a parameterized query based upon a
DateTime field against an Access data source, you will receive the
following error:
ODBC Error: 22005: [Microsoft][ODBC Microsoft Access 97 Driver] Data
type mismatch in criteria expression.
CAUSE
The conditions that cause this error are as follows:
- Using an Access data source. This behavior does not occur against a
SQL data source.
- Search criteria on a Date/Time Data type field.
- User enters the value of the search criteria in the form of 'mm/dd/yy'
RESOLUTION
There are two situations where you need to apply a workaround to this
behavior:
- When executing this type of query in the Query Designer, such as in
testing the query before saving the Active Server Pages (ASP) script, it
is best to hard code a test date in the criteria field in the "Grid
Pane" and then run the query (see step 7 under Steps to Reproduce
Behavior" in the MORE INFORMATION section below).
- When executing this type of query in the ASP script, you must change the
code that the Design-Time Control outputs to one of the below formats:
Hard Coded Date:
cmdTemp.CommandText = "SELECT ClimbingTopSales.*,
ClimbingTopSales.ProductIntroductionDate FROM ClimbingTopSales WHERE
(((ClimbingTopSales.ProductIntroductionDate) =#4/23/96#))"
Parameterized Date:
cmdTemp.CommandText = "SELECT ClimbingTopSales.*,
ClimbingTopSales.ProductIntroductionDate FROM ClimbingTopSales WHERE
(((ClimbingTopSales.ProductIntroductionDate) = #"
& strQueryDate & "#))"
STATUS
This problem has been resolved in Visual InterDev 6.0.
REFERENCES
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
Modification Type: | Minor | Last Reviewed: | 3/9/2005 |
---|
Keywords: | kbPubTypeKC kbMSCCSearch kbDtQDesigner kberrmsg kbprb KB175258 |
---|
|