Replace Single Quotes

This script will replace single quotes so the data is SQL-safe

Public
Tested
My Own Work
<%
Function fncReplaceSingleQuotes( ByVal strToReplace )
On Error Resume Next
Const Proc = "fncReplaceSingleQuotes"

strToReplace = Replace(strToReplace, "'", "''")

fncReplaceQuote = strToReplace

If err.Number <> 0 then
Call subWriteError(err.Number, Proc, err.Description)
End if

End Function
'
' ...
'
strVar = Request.Form("txtField1")
strVar = fncReplaceSingleQuotes(strVar)
%>

Views 3091 Downloads 1018

Classic ASP Texts + Strings
JeffSmith
26
Revisions

v1.0