Microsoft KB Archive/125226

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

Article ID: 125226

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.51

 Microsoft Visual C++ 2.0 Professional Edition 

-



This article was previously published under Q125226



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-

</li>  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-

</li>  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",...); </li></ul>

<div class="moreinformation_section">

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

Additional query words: 1.50 2.00 2.50 2.51 3.00 update reserved keyword

Keywords: kbprb KB125226

-

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

© Microsoft Corporation. All rights reserved.