Microsoft KB Archive/139996

From BetaArchive Wiki
Knowledge Base


BUG: Wizards Create Invalid Column Names for QueryDef Join

Article ID: 139996

Article Last Modified on 1/6/2004



APPLIES TO

  • The AppWizard, when used with:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 4.1 Subscription
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++ 6.0 Standard Edition
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition
  • The ClassWizard, when used with:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 4.1 Subscription
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++ 6.0 Standard Edition
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition



This article was previously published under Q139996

SYMPTOMS

If you use AppWizard or ClassWizard to create a MFC DAO recordset based on a predefined query (QueryDef) that joins tables that contain columns with identical names, the application generates an exception when it attempts to open the recordset. The exception indicates that:

   '[table.column]' isn't a valid parameter name.
                

where table and column correspond to actual table and column names in your database.

Note In Visual C++ 6.0, the AppWizard creates a CdaoRecordset-derived class for the application based on the query. At run-time, you receive the following error message:

Invalid bracketing of name '[table.column]'

Note In Visual C++ .NET 2002 and Visual C++ .NET 2003, the AppWizard creates a CRecordset-derived class for the application based on the query. At run-time, you receive the following error message:

is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

CAUSE

The exception is thrown due to the incorrect manner in which the wizards add delimiting brackets to the standard table_name.column_name references in your CDaoRecordset-derived class's DoFieldExchange.

The wizards generate the following syntax:

   [table.column]
                

The correct syntax is:

   [table].[column]
                

RESOLUTION

You must manually modify the DoFieldExchange of the CDaoRecordset-derived class or the CRecordset-derived class to correct those column references that use the incorrect syntax. Follow these steps:

  1. Do not add qualifiers to any columns that are not duplicates. Qualifying columns where no ambiguity exists will result in errors. For additional information, please see the following article in the Microsoft Knowledge Base:

    139994 Specifying Table Name with Column Name in MFC DAO

  2. Modify the wizard-generated code to delimit the table and column names correctly. For additional information about the exact form of the final column reference is described in detail, please see the following article in the Microsoft Knowledge Base:

    139997 Item not found in this collection" with MFC DAO Join


STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kbdatabase kbwizard kbpending KB139996