Comment character problem in SQL statement / ASP VBscript
Posted on 2004-11-15
I am using some variables in my INSERT INTO SQL statement and I noticed that when one of my variables contains a VB comment (') character I get an error message about sql string syntax error. Logcaly I understand what is hapening, but still ..... is there a simple solution to this?
This is what my variable looks like
MyVar = "abc123-2'" // abc123-2' - so the variable has ' sign in the end
And the statement is
mySQL = "INSERT INTO "MyTableName" (Column1, Column2) VALUES ('" & TextVar & "','" & MyVar & "')"
I wonder,,, :)
Thanks in advance