PRB: Wizard Doesn't Generate Column or Param Map for Jet (191356)



The information in this article applies to:

  • Microsoft OLE DB, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q191356

SYMPTOMS

Using the ATL OLE DB Consumer Wizard with a Jet Query causes the Wizard to not generate column maps and parameter maps in the accessor class that it creates.

CAUSE

The Microsoft Jet 3.51 OLE DB Provider does not support the PROCEDURE_COLUMNS or the PROCEDURE_PARAMETERS rowsets, which are required for the ATL wizard, to provide necessary information for generating the column and parameter maps.

RESOLUTION

The following are two suggested workarounds for these issues.

Workaround 1: Generating Correct Column Map for Jet Queries with Microsoft Jet 3.51 Provider

  1. Create a Jet table that returns the same columns as the Jet Query.
  2. Use the Consumer Wizard on the Jet table instead of the Query.
  3. Change the generated DEFINE_COMMAND macro <TableName>.h file so that it references the query instead of the table; for example
          DEFINE_COMMAND(CEmpAccessor, _T(" \ 
            SELECT \ 
              id, \ 
              fname, \ 
              lname  \ 
            FROM emp"))
    						
    becomes the following:
          DEFINE_COMMAND(CEmpAccessor, _T(" \ 
            SELECT \ 
              id, \ 
              fname, \ 
              lname  \ 
            FROM empQuery"))
    							

Workaround 2: Generating Correct Parameter Map for Jet Queries with Microsoft Jet 3.51 Provider

  1. Use the Consumer Wizard on the Jet Query (that uses parameters) with the Microsoft Jet 3.51 OLE DB Provider as you would expect. Note the missing column and parameter maps in the <QueryName>.h file.
  2. In a temporary project, use the Consumer Wizard with the Microsoft OLE DB Provider for ODBC providers with the Jet Query. This provider creates the proper column and parameter maps.
  3. From the temporary project in step 2, copy the C<QueryName>Accessor class generated in the <QueryName>.h file.
  4. Replace the C<QueryName>Accessor class in your real project with the one copied from step 3.
  5. Finally, the Microsoft Jet 3.51 Provider does not support the command syntax that the consumer wizard generates, and effectively does not support calling stored queries with parameters. To work around this limitation, the stored query text must be copied and used as the command text.
For example, Wizard output command:
      DEFINE_COMMAND(CQueryAccessor, _T("{ CALL EmpLName (?) }"))
				
Change to Stored Query definition:
      DEFINE_COMMAND(CQueryAccessor, _T("PARAMETERS pId Short; SELECT
         emp.lname FROM emp WHERE emp.id = pId;"))
				

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

This behavior is known to happen with the Microsoft Jet 3.51 Provider, version 3.52.1527.4, which shipped with Visual C++ 6.0.

MORE INFORMATION

The Microsoft OLE DB Provider for ODBC in conjunction with the Access ODBC driver that shipped with Visual C++ 6.0 provide the necessary functionality for the Consumer Wizard to generate code that works in calling Jet Stored Queries.

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbConsumer kbDatabase kbDTL kbJET kbMDAC210fix kbMDACNoSweep kbprb kbProvider kbwizard KB191356 kbAudDeveloper