PDA

Click to See Complete Forum and Search --> : Problems with buildind sql string


Ianpbaker
Mar 23rd, 2000, 06:21 PM
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

Forest Dragon
Mar 23rd, 2000, 09:01 PM
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!!!

Ianpbaker
Mar 23rd, 2000, 10:15 PM
That works (it doesn't return an error) But when I view the field where the data has changed a ¬ character is shown

JHausmann
Mar 24th, 2000, 12:07 AM
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.

Forest Dragon
Mar 24th, 2000, 01:33 AM
lanpbaker:

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