Click to See Complete Forum and Search --> : how to format input string that contains single quote?


eeccll
01-12-2006, 05:56 AM
hihi.. does anyone know how to format input string which contains single quote, before insert into database? :confused: I found information from net, giving this example:


strUserData=Quotes(request.form("T1"))
strSQLData="select Name from UserNames where Name='" & strUserData & '"

Function Quotes(strInput)
strInput=replace(strInput,"'","''")
End Function


but the input string become empty.. can anyone help me?? I'm doing asp.net with VB language.. thankssss..

juicemousezero
01-12-2006, 09:53 AM
I'm guessing that strInput is being lost between the function call and the function itself... try putting this in.


strUserData=Quotes(request.form("T1"))
strSQLData="select Name from UserNames where Name='" & strUserData & '"

Function Quotes(ByVal strInput As String) As String
strInput=replace(strInput,"'","''")

Return strInput
End Function

eeccll
01-12-2006, 10:57 AM
yes, you are right.. thanks!! :)

juicemousezero
01-12-2006, 12:54 PM
Cool cool... that good ol Return word thingy. Can't go wrong.