deliriumxx
asked on
Comment character problem in SQL statement / ASP VBscript
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?
Example:
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
Delirium
Example:
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
Delirium
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yayyyyy.... :) I had a little typo... works :)
Thank you very very much!! I don't know why I didn't think of Replace....
Guess the hours got to my concentration.
Thanks,,, a lot :) !
Thank you very very much!! I don't know why I didn't think of Replace....
Guess the hours got to my concentration.
Thanks,,, a lot :) !
It's ok, deliriumxx. Glad could make helps here 8-) cheers
ASKER
Any other ideas? LOL