Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Getting a "query is too complex" error

I have it set to update a pretty big record. I'm able to save it fine with almost identical code but when I try to update it I get this error. The only difference is when I save it I wrote the query "select * from tblProducts order by item_ID" and for update I have it written "select * from tblProducts where item_ID=" & itemID. Does anyone know why I'd get an error? This is the only part that's any different.

Comments

  • haiprogrammershaiprogrammers Member Posts: 7
    You haven't specified which database u r using, but still I can try.

    I think u should write the SQL statement like this :

    "select * from tblProducts where item_ID='" & itemID & "'"

    or

    "select * from tblProducts where item_ID='" & itemID.text & "'"

  • infidelinfidel Member Posts: 2,900
    : You haven't specified which database u r using, but still I can try.
    :
    : I think u should write the SQL statement like this :
    :
    : "select * from tblProducts where item_ID='" & itemID & "'"
    :
    : or
    :
    : "select * from tblProducts where item_ID='" & itemID.text & "'"

    If the item_ID field is numeric, there should be no quotes around the value.

    If the question was about updating a record, why are you using SELECT statements?
  • bednarjmbednarjm Member Posts: 82
    Don't you want an update statement instead of a select statement?

    One comment, select * from ... is usually not very efficient (and not very good programming practice). It's usually much better to list the field names (select field1, field2 from ...) and only bring back the fields needed. This saves network overhead and server resources (the database engine doesn't have to translate the select * into the field names).

    Just a thought,

    jim b
  • HGeneAnthonyHGeneAnthony Member Posts: 92
    I'm using an ADO database. I use the exact same select statement earlier in the code to return a record and I have no problem. I got the error on RS.Update. The code is identical (for the most part) when I create the record (which works) I just get the error when I try to do the update the existing record. I also used a "select * from" statement because I update all fields in the record. I do have roughly 40 fields in a record. I don't know if the amount of fields makes a difference?



    : Don't you want an update statement instead of a select statement?
    :
    : One comment, select * from ... is usually not very efficient (and not very good programming practice). It's usually much better to list the field names (select field1, field2 from ...) and only bring back the fields needed. This saves network overhead and server resources (the database engine doesn't have to translate the select * into the field names).
    :
    : Just a thought,
    :
    : jim b
    :

  • lionblionb Member Posts: 1,688 ✭✭
    : I'm using an ADO database. I use the exact same select statement earlier in the code to return a record and I have no problem. I got the error on RS.Update. The code is identical (for the most part) when I create the record (which works) I just get the error when I try to do the update the existing record. I also used a "select * from" statement because I update all fields in the record.

    How can you make [blue][b]update[/b][/blue] using [B][blue]SELECT[/blue][/b] statement?????

    I do have roughly 40 fields in a record. I don't know if the amount of fields makes a difference?
    :
    :
    :
    : : Don't you want an update statement instead of a select statement?
    : :
    : : One comment, select * from ... is usually not very efficient (and not very good programming practice). It's usually much better to list the field names (select field1, field2 from ...) and only bring back the fields needed. This saves network overhead and server resources (the database engine doesn't have to translate the select * into the field names).
    : :
    : : Just a thought,
    : :
    : : jim b
    : :
    :
    :

  • Andre YoungAndre Young USAMember Posts: 0

    ______ { http://forcoder.org } free ebooks and video tutorials about || Delphi, C, Objective-C, Assembly, JavaScript, Ruby, Scratch, Go, Java, PHP, R, Visual Basic .NET, Swift, Visual Basic, Perl, PL/SQL, C#, MATLAB, Python, C++ Transact-SQL, Crystal, Lisp, Logo, Prolog, F#, FoxPro, LabVIEW, Hack, Rust, Ada, SAS, Scala, Awk, Alice, VBScript, Apex, Dart, Erlang, Julia, D, COBOL, Bash, ML, Scheme, Lua, ABAP, Fortran, Clojure, Kotlin || __________

Sign In or Register to comment.