Click to See Complete Forum and Search --> : Replace all occurrences of ...


gift2women
06-26-2009, 03:28 PM
I'm not sure if this should be a SQL or ASP inquiry... so, sorry if I'm in the wrong spot.

I understand how to replace a single problem in a Form field:
Replace(Request.Form(*), "'", "& #39;")
(to replace all my apostrophes with the apostrophe character)

I understand how to replace multiple problems in a Form field:
Replace(Replace(Request.Form(*), "'", "& #39;"), chr(13), "<br>")
(to replace all my apostrophes with the apostrophe character and all carriage returns with a line break)

I want to replace all occurrences of " ' " and " chr(13) " from ALL Form fields before it updates my database. How can I do this?

russell
06-27-2009, 11:46 AM
You need to explicitly perform the replace for each field. You could put all the form values into an array and loop it, but then you wouldn't know which is which to put into your SQL statement. Of course, if you were using the command object and stored procedures you wouldn't need to do this at all.