PRB: Update or Delete Record Gives Error: Query is too complexID: Q125651
|
When trying to update or delete a record of a CRecordset object, the
following message occurs:
DBMS: ACCESS, Version: 2.0 Query is too complex. State:S1000[Microsoft][ODBC Microsoft Access 2.0 Driver]
DBMS: ACCESS , Version: 2.0 Query is too complex. State:S1000,Native:-3071,Origin:[Microsoft] [ODBC Microsoft Access 2.0 Driver]
The error occurs when the cursor library is loaded and the recordset
retrieved by the CRecordset is opened as a snapshot object that contains
more than 40 bound columns.
By default, the cursor library is loaded when a CRecordset is opened. MFC
snapshots perform positioned updates and deletes by using the ODBC SQL
WHERE CURRENT OF syntax. The cursor library changes the WHERE CURRENT OF
clause to a full WHERE clause using all the columns in the recordset.
For example, the MFC Database classes might create the following SQL
statement when updating a record:
Update table1
SET column1=?
WHERE CURRENT OF XXXXX
The cursor library knows which record the application is currently
positioned at and converts the WHERE CURRENT OF clause into a WHERE clause
that will update the current record only. For example, assume the recordset
has three columns. The cursor library changes the SQL statement to:
Update table1
SET column1=?
WHERE column1=<current value> AND column2=<current value> AND
column3 =<current value>
Here <current value> represents the value of that column before the update
is performed.
To work around this behavior, do one of the following:
Q124915 SAMPLE: Using Dynasets with the 16-Bit MFC Database ClassesSpecial code must be acquired to use dynasets with the 16-bit MFC Database classes. CRecordsets which use a dynaset use the SQLSetPos() ODBC 2.0 functionality to perform positioned updates and deletes. This means the MFC database classes do not need to construct an SQL statement to send to the ODBC driver. A call to the SQLSetPos() function of the driver is all that is necessary to perform the update or delete.
This behavior is by design.
Appendix G of the ODBC 2.0 Programmer's Reference contains information
about the cursor library. The ODBC Programmer's Reference is available in
the onine books for Visual C++ version 2.0 or greater.
MFC TechNote #45 contains additional information about MFC support for long
binary data and the use of RFX_LongBinary.
Additional query words:
Keywords : kbDatabase kbMFC kbODBC kbVC kbVC150 kbVC151 kbVC152 kbVC200 kbVC210 kbVC400 kbVC410 kbVC500 kbVC600
Version : 1.50 1.51 1.52 | 2.00 2.10 4.00
Platform : NT WINDOWS
Issue type :
Last Reviewed: August 5, 1999