Results 1 to 5 of 5

Thread: Problems with buildind sql string

  1. #1

    Thread Starter
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Problems with buildind sql string

    can somone please advise me on ways not to go on this site ever again as it is so fecking addictive and will completly take over my life



    The application I am building has a update facility that takes values from access puts them into varios text boxes, lets the user change the value (etc)

    I then build a sql string and do a db.execute to update the string is built as below.

    strSQL = "UPDATE tblhotels " & _
    "SET hotelkey = '" & txtHotelkey & "'," & _
    "accomodationtype = " & cboacomtype & "," & _
    "starrating = '" & Cbostars & "'," & _
    "hotelname = '" & txtname & "'" & _
    " WHERE hotelkey = '" & strHotelkey & "'"

    This works fine as long as there are no ' in the text

    is there any way of getting around this
    Last edited by Ianpbaker; Jul 3rd, 2001 at 02:52 AM.

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253
    You can copy the contents of any TextBox to a string, and then search it and add another ' after each ' you find. Finally, execute the query.

    Good Luck!!!

  3. #3

    Thread Starter
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    That works (it doesn't return an error) But when I view the field where the data has changed a ¬ character is shown

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    You could also

    1) disallow the use of characters by doing a keystroke check when the data is typed into the text fields _or_
    2) use double quotes as your delimiter (makes getting the sql right a bit harder.

  5. #5
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253
    lanpbaker:

    Which application did you use to view the field value?
    Try to put it in a TextBox and tell me what happens.

Posting Permissions

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



Click Here to Expand Forum to Full Width