Microsoft KB Archive/139996

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

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

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

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

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

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

 Microsoft Visual C++ .NET 2002 Standard Edition</li></ul>

 Microsoft Visual C++ .NET 2003 Standard Edition</li></ul> </li> The ClassWizard, when used with:  <li>Microsoft Visual C++ 4.0 Standard Edition</li></ul>

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

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

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

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

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

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

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

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

<ul> <li>Microsoft Visual C++ .NET 2002 Standard Edition</li></ul>

<ul> <li>Microsoft Visual C++ .NET 2003 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q139996

<div class="symptoms_section">

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: <pre class="fixed_text">  '[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.

<div class="cause_section">

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: <pre class="fixed_text">  [table.column] The correct syntax is: <pre class="fixed_text">  [table].[column]

<div class="resolution_section">

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: <ol> <li>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

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

</li></ol>

<div class="status_section">

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

-

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

© Microsoft Corporation. All rights reserved.