M
MS
Hi,
When doing SQL statements apostrophes mark the start and end of a text
field, accordingly any apostrophe in the text must be handled.
So here's a code snippet showing how I handle this:
int isApostrophe = title.indexOf("'");
if (isApostrophe != -1)
{
title = title.replaceAll("'", "\\'");
}
I search to see if the text has an apostrophe, if there is a match in the
text (String title) replace all the apostrophes with "\\'" so that the
following conversion will take place:
"Matthew's test" should become "Matthew\'s test" and the sql, when run,
should be happy as it knows the apostrophe in the middle of the text is
not the end of the text.
BUT this is not happening "Matthew's test" is remaining the same. I'm
probably being stupid but I can't work out what's wrong with my code.
Please help,
MS
When doing SQL statements apostrophes mark the start and end of a text
field, accordingly any apostrophe in the text must be handled.
So here's a code snippet showing how I handle this:
int isApostrophe = title.indexOf("'");
if (isApostrophe != -1)
{
title = title.replaceAll("'", "\\'");
}
I search to see if the text has an apostrophe, if there is a match in the
text (String title) replace all the apostrophes with "\\'" so that the
following conversion will take place:
"Matthew's test" should become "Matthew\'s test" and the sql, when run,
should be happy as it knows the apostrophe in the middle of the text is
not the end of the text.
BUT this is not happening "Matthew's test" is remaining the same. I'm
probably being stupid but I can't work out what's wrong with my code.
Please help,
MS