Microsoft KB Archive/164954

= PRB: "Syntax Error in Number in Query Expression" =

Article ID: 164954

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 2.2

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul>

<ul> <li>Microsoft Visual C++ 1.52 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q164954

<div class="symptoms_section">

SYMPTOMS
When a floating-point error occurs in your program before a call to a database function such as CRecordset::Open, CDaoRecordset::Open, or CdbRecordset::Open, which uses the Access Jet database engine, the call may incorrectly generate the following error:

Syntax error in number in query expression

<div class="resolution_section">

RESOLUTION
To solve this problem, fix the floating-point error in your code or call _fpreset before the call to Open.

<div class="moreinformation_section">

MORE INFORMATION
This error may be incorrectly generated when opening an Access database, using either ODBC or DAO. The error occurs if the filter string or WHERE clause contains a numeric value, and a floating-point error has occurred somewhere in your program.

Sample Code
/* Compile options needed: none */

/* The following code generates the error message: * "Syntax error in number in query expression". *    * To avoid the error, comment out the line that generates the * floating-point error (LINE 1), or remove the comment from the line * containing the call to _fpreset (LINE 2). */

/* CMySet is derived from CDaoRecordset for the Student table from the * STDREG32.MDB database, which is included with the DAOENROL sample. */    CMySet rs;

// Cause a floating-point error to occur. double x = 12345.6789; double y = 0.0; double z = x / y;      // LINE 1: comment out to avoid error

// _fpreset;             // LINE 2: remove comment to avoid error try {       rs.m_strFilter = "StudentID = 1001"; rs.Open; }   catch( CDaoException* e ) {       AfxMessageBox( e->m_pErrorInfo->m_strDescription ); e->Delete; }   rs.Close;

Additional query words: FindFirst Jet

Keywords: kbprb KB164954

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.