admin
05-29-2003, 03:30 PM
When an apostrophe ( ' ) is inserted into an insert string errors will occur. The following will cause errors:
LastName = "O'Neal"
Conn.Execute "INSERT (LastName) VALUES ('"&LastName &"')"
The following function will solve this problem:
FUNCTION theFIX( theVariable )
theFIX=Replace(theVariable, "'", "'")
' this replaces a single apostrophe ( ' ) with two single apostrophes ( ''). Note: two single apostrophes, not one quotation mark
END FUNCTION
Now use the function in the string:
Conn.Execute "INSERT (LastName) VALUES ('" &theFIX(Request("LastName")) & "')"
LastName = "O'Neal"
Conn.Execute "INSERT (LastName) VALUES ('"&LastName &"')"
The following function will solve this problem:
FUNCTION theFIX( theVariable )
theFIX=Replace(theVariable, "'", "'")
' this replaces a single apostrophe ( ' ) with two single apostrophes ( ''). Note: two single apostrophes, not one quotation mark
END FUNCTION
Now use the function in the string:
Conn.Execute "INSERT (LastName) VALUES ('" &theFIX(Request("LastName")) & "')"