PRB: Datatype Mismatch Errors in Access Parameterized Date QueryID: Q175258
|
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.
The conditions that cause this error are as follows:
There are two situations where you need to apply a workaround to this behavior:
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 & "#))"
This problem has been resolved in Visual InterDev 6.0.
If a date, such as 4/23/96 is entered in the criteria column, then it automatically converts the date to the following format and successfully runs the query:
= { ts '1996-04-23 00:00:00' }
The CommandText parameter reads as follows:
cmdTemp.CommandText = "SELECT ClimbingTopSales.* FROM ClimbingTopSales
WHERE (ProductIntroductionDate = { ts '1996-04-23 00:00:00' })"
The above syntax will run in ASP and display the correct results.
= [qryDate]
ODBC Error: 22005: [Microsoft][ODBC Microsoft Access 97 Driver] Data type mismatch in criteria expression.
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:
http://support.microsoft.com/support/vinterdev/
Additional query words:
Keywords : kberrmsg kbAccess kbADO kbVisDBTools kbVisID600 kbGrpASP kbDtQDesigner
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 11, 1999