A
Function to Replace Apostrophes LastName =
"O'Neal" The following function will solve this problem:
FUNCTION theFIX( theVariable ) Now use the function in the string:
Conn.Execute
"INSERT (LastName) VALUES ('" & theFIX(Request("LastName"))
& "')"
When an apostrophe ( ' ) is inserted into an insert string
errors will occur. The following will cause errors:
Conn.Execute "INSERT (LastName) VALUES ('" & LastName &
"')"
theFIX=Replace(theVariable, "'", "’")
' this replaces an apostrophe ( ' ) with alt 0146 ( ’ ). Note: it looks
the same but it is not keyboard apostrophe.
END FUNCTION
Solving
the Apostrophe Problem SQL="UPDATE table SET field="'
& Replace(sText,"'","’")& '" WHERE
somecondition = somecondition
Apostrophes ( ' ) can be very annoying; however, there is
a simple fix.... use the Replace function:
This replaces an apostrophe with alt 0146 (the special apostrophe). More
Special Characters
from the keyboard
'
from the alt code
’
Or my favorite way
sProduct = Request.Form("Product")
Product = Replace(sProduct,"'","’")