FIX: Parameter Mismatch with Subqueries When Using Access ODBC Driver (244719)
The information in this article applies to:
- Microsoft ODBC Driver for Access 4.0
- Microsoft Data Access Components 2.1
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
This article was previously published under Q244719 SYMPTOMS
When executing a parameterized query that contains a subquery, when using the Microsoft Open Database Connectivity (ODBC) Driver for Access, various unexpected problems occur.
Reported problems include unexpected results (no records returned or the wrong records returned) or other errors indicating a type mismatch or a numeric value out of range.
CAUSE
This problem is caused by a bug in the underlying Microsoft Jet 4.0 engine that is included with the Microsoft Data Access Components (MDAC) versions noted above.
Parameters markers in ODBC are typically mapped from left to right with no regard as to whether they are in the main query or a subquery. When you have a main query and a subquery, Jet maps the subquery parameters first and maps the main query parameters next. Therefore, in most cases, the parameters are mapped in a different order than expected. This parameter mapping order means that unexpected parameter values are passed in to one or more of the parameters and can result in unexpected query results or type mismatch errors (for example, if a text value is passed into a numeric parameter).
For example, the following SQL query has four parameters for fields A, B, C, and D:
SELECT * FROM MainTable
WHERE A=? AND B=? AND
E IN ( SELECT E FROM SubQueryTable WHERE C=? AND D=?)
Normally in ODBC the programmer expects the parameters to be bound in the order A, B, C, D; however, because of this particular bug in Microsoft Jet, the parameters are bound in the order C, D, A, B.
RESOLUTION
A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next service pack for Microsoft Data Access Components that contains this fix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Jet 4.0 Service Pack 4.
For additional information about how to download the latest Jet 4.0 service pack, click the following article number to view the article in the Microsoft Knowledge Base:
239114
How To: Obtain the Latest Service Pack for the Microsoft Jet 4.0 Database Engine
Modification Type: | Major | Last Reviewed: | 4/7/2006 |
---|
Keywords: | kbQFE KBHotfixServer kbBug kbDatabase kbfix kbJET kbMDAC260fix kbMDACNoSweep KB244719 |
---|
|