PRB: ODBC Reserved Word in a RFX Function Causes Syntax Error

Last reviewed: July 10, 1997
Article ID: Q125226
1.50 1.51 | 2.00
WINDOWS   | WINDOWS NT
kbprg kbprb

The information in this article applies to:

   The Microsoft Foundation Classes (MFC), included with:
    - Microsoft Visual C++ for Windows, versions 1.5, 1.51
    - Microsoft Visual C++, 32-bit Edition, version 2.0

SYMPTOMS

An attempt to update a data source produces a command failed message box and MFC Trace output:

   Syntax error in UPDATE statement.
   State:37000,Native:-3503,Origin:
   [Microsoft][ODBC Microsoft Access 2.0 Driver]

CAUSE

Using an ODBC reserved word as the second parameter (char* szName) in an RFX function causes the syntax error. The parameter represents the table's column name. For example, the following code causes the error:

void CMyRecordset::DoFieldExchange(CFieldExchange *pFX)
{ ...

  RFX_Date(pFX, "date", ...); // error "date" is ODBC reserved word!

... }

NOTE: Another scenario that will cause a similar error is caused by using a reserved Access word for a table name, then trying to insert the table via MFC and ODBC.

RESOLUTION

Implement one of the following solutions:

  • Change the name of the column in the data source's table. For example, change DATE to BIRTHDATE. DATE is a reserved word.

    -or-

  • Enclose the column name in square brackets when you use it in the RFX function in CRecordset::DoFieldExchange. For example:

    change this:

          RFX_Date (pFX, "Date",...);
    

    to this:

          RFX_Date(...,"[Date]",...);
    

    -or-

  • Qualify the column name with a table name (as MSQuery does) in the RFX function in CRecordset::DoFieldExchange. For example,

    Change this:

          RFX_Date(..., "Date",...);
    

    to this:

          RFX_Date(..., "table1.Date",...);
    

MORE INFORMATION

For a list of ODBC reserved words, see Appendix C of the ODBC Programmer's Reference.


Additional reference words: 1.50 2.00 2.50 2.51 3.00
KBCategory: kbprg kbprb
KBSubcategory: MfcDatabase
Technology : kbMfc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.