The information in this article applies to:
SYMPTOMSWhen using a SHAPE statement to retrieve parent and child records, the SHAPE provider pulls down all child records regardless of whether there is a matching parent record. CAUSEThe SHAPE provider relies exclusively on the child statement to determine which records to return. RESOLUTIONModify the child statement to restrict the records returned to match only those related to the parent records. STATUSThis behavior is by design. MORE INFORMATION
The SHAPE provider is a data-provider-neutral service provider. It works by
reading the parent and child records into temporary tables on the local
machine and using the Client Cursor Engine to dynamically filter the child
records according to the value of a field in the current parent record.
the SHAPE provider does not know how to modify the second SELECT statement
in order to restrict the records to just Nancy Davolio. In fact, it does
not even know that the parent records are being restricted at all. Because
of this, all Orders for all employees are read into the local buffer.
There are two workarounds, which are detailed below. Use a Parameterized SHAPE StatementOne workaround, especially if the parent recordset will just contain a single record, is to use a Parameterized SHAPE statement:
In this case, the SHAPE provider reads the parent records first. It then
queries for the child records as each parent record is visited. If the
parent recordset contains a single record, then this is very efficient. If
it contains more records, then a separate query to retrieve child records
will be executed for each parent record visited. The child records are
cached, so this does not add overhead if parent records are visited
multiple times.
Use a JOIN in the Child StatementAnother workaround is to make the child statement more complex so that it reflects any restrictions placed upon the parent statement. This can be accomplished through a JOIN:
If the parent and child tables do not have a one-to-many relationship; that
is, if EmployeeID is not a unique index or Primary Key of the Employees
table, the following alternative syntax using a sub-select is more general
and will work in all cases:
This is somewhat more expensive in terms of server processing, but makes up
for it in terms of reduced network traffic.
NOTE: The SQL syntax given above will work with Microsoft SQL Server and Microsoft Jet. Other data providers may require different syntax to accomplish the same goals. REFERENCESFor additional information on SHAPE syntax, please see the following article in the Microsoft Knowledge Base: Q189657 HOWTO: Use the ADO SHAPE Command © Microsoft Corporation 1998, All Rights Reserved. Additional query words: kbDSupport kbdse
Keywords : kbDatabase kbOLEDB kbVBp600 kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbMDAC210SP2 |
Last Reviewed: November 18, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |