Link to home
Start Free TrialLog in
Avatar of deliriumxx
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
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deliriumxx
deliriumxx

ASKER

Invalid character is what I get now. Hm...

Any other ideas? LOL
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 :) !
It's ok, deliriumxx. Glad could make helps here 8-) cheers