Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Angry Unanswered: Error in SQL Query

    Hello people,

    I am trying to build an update query in run-time, I get to build this query:

    "UPDATE Supplier SET SupplierName='Walter's co MM', SupplierCode=3333, Remark='try MM' WHERE SupplierPK=4"

    If I write this query "UPDATE Supplier SET SupplierName='Walter's co MM' WHERE SupplierPK=4" it works perfectly.

    There is a error message about "missing operator", but this is the typical error that you are looking hours and hours to the screen and you don't find anything wrong. I am working with this since 2 hours ago.

    Can anybody see the error.

    Thanx a lot.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Try:

    "UPDATE Supplier SET SupplierName='Walter's co MM', SupplierCode='3333', Remark='try MM' WHERE SupplierPK=4"

  3. #3
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Talking

    EY CyberLynx!!

    Thanks. Finally I succeded. It wasn't the thing you told me, since SupplierCode is a number. But I was doing some changes to the code, trying and trying, finally it works, and I don't know why, maybe some space in blank. Bo! I don't know.

    I am happy anyway, after 2 hours.

    Thanks for your help.

  4. #4
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    Ok, now I got what is the reason. It is because the SupplierName contains a ' character, and then it comes the problem.

    Then the string that I build for the SQL query "thinks" that is the end of the text. How can I solve the problem since I would like to allow this character?

    Thank you in advance.

  5. #5
    Join Date
    Jan 2004
    Posts
    492
    Originally posted by pipeio
    Ok, now I got what is the reason. It is because the SupplierName contains a ' character, and then it comes the problem.

    Then the string that I build for the SQL query "thinks" that is the end of the text. How can I solve the problem since I would like to allow this character?

    Thank you in advance.
    Use 2 single quotes '' inside a string to simulate a single quote. NOTE, these are 2 SINGLE quotes, and not one DOUBLE quote.

    Code:
    "UPDATE Supplier SET SupplierName='Walter''s co MM', SupplierCode='3333', Remark='try MM' WHERE SupplierPK=4"
    This should fix that problem.

  6. #6
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    EYYY, with your help and with the Replace function, all is fixed

    Thanx, thanx, thanx a lot

    I have been with this problem almost all the day. I didn't know why sometimes the SQL worked and sometimes didn't, it was because of the f&&& '

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •