PDA

View Full Version : مشکل در Update کردن رکوردست : Query is too complex



javid_p84
جمعه 23 بهمن 1383, 20:45 عصر
سلام
خسته نباشین :mrgreen:
یه مشکل اساسی دارم ممنون میشم کمک کنین
وقتی توی VB کد زیر رو میخوام اجرا کنم خطای Query is too Complex

For i = 0 To Fix((rstTtable.Fields.Count / 2)) - 3
rstTtable.Fields((2 * i) + 5).Value = IIf(Trim(frm.Text1(i).Text) <> "", Trim(frm.Text1(i).Text), "")
rstTtable.Fields((2 * i + 1) + 5).Value = IIf(Trim(frm.Text2(i).Text) <> "", Trim(frm.Text2(i).Text), "")
Next i

rstTtable.Fields(1).Value = IIf(Trim(frm.Text1(22).Text) <> "", Trim(frm.Text1(22).Text), "")
rstTtable.Fields(2).Value = IIf(Trim(PicAdr) <> "", PicAdr, "")
rstTtable.Fields(4).Value = IIf(Trim(frm.Text1(23).Text) <> "", Trim(frm.Text1(23).Text), "")
rstTtable.Update

:kaf: :strange:

ممنون
:موفق:

Behrouz_Rad
جمعه 23 بهمن 1383, 21:41 عصر
Query is too complex. (Error 3360)

The query is too complex. Reduce the number of fields in the SELECT clause or the number of subqueries or tables in the join.

1. Generally speaking, the error appears when the table to be updated has
more than 99 fields. This behavior occurs because the default behavior of
ADO is to use each field in the recordset to determine the record to be
updated on the server. That is, when the update is attempted, a SQL Update
query is sent to the server. Part of this query is a WHERE clause that is
used to identify the record to be updated. An AND clause appears within the
WHERE clause for each field to be used in that identification. Updating a
recordset with more than 40 fields involves a WHERE clause with more than
40 ANDs.

The Jet engine allows only 40 AND clauses within a SQL WHERE or HAVING
clause. Jet 3.51 increased this limit to 50 AND clauses, and Jet 4.0
increased the limit to 99 AND clauses.

In order to avoid more than 99 fields are involved while updating a record,
I suggest you to add a primary key to the underlying table, which ensures
that a unique key is used to identify the record to be updated, rather than
the default behavior of using every field.

For your reference, here is a related article on this kind of issue:

HOWTO: Update More Than 40 fields in an Access (Jet) Database

http://support.microsoft.com/?id=192716