jimmywages
Programmer
Hi Y'all,
I'm trying to write a string to a database using SQL and since SQL doesn't like single quotes, I had to replace it with 2 single quotes...
Replace(MyString, "'", "''"
I thought this was an "escape" sequence... meaning 2 single quotes is interpreted as 1 single quote... But this is not the case.. When I look into the database, I see that it's added two single quotes inside there as well!
So (in the database) instead of: It's a nice day. I get: It''s a nice day.
How do I avoid actually adding 2 single quotes into the database yet not causing SQL to give me errors?
Any help would be appreciated!
~jimmy.
I'm trying to write a string to a database using SQL and since SQL doesn't like single quotes, I had to replace it with 2 single quotes...
Replace(MyString, "'", "''"
I thought this was an "escape" sequence... meaning 2 single quotes is interpreted as 1 single quote... But this is not the case.. When I look into the database, I see that it's added two single quotes inside there as well!
So (in the database) instead of: It's a nice day. I get: It''s a nice day.
How do I avoid actually adding 2 single quotes into the database yet not causing SQL to give me errors?
Any help would be appreciated!
~jimmy.