Hi mustang,
Originally posted by mustang india:
Why cant we use just this
String s = "This is ''' my string";
System.out.println(s);
s = s.replace('\'', '\"');
System.out.println(s);1
This prints out
This is ''' my string and
This is """ my string
But the string that will be stored in the database will be "This is """ my string", and not the original "This is ''' my string".
What my code did was to replace a single apostrophe with two, which, to a certain effect, the first apostrophe is a sort of escape character that tells SQL Server to accept the second apostrophe as data. I used the replace() method in StringBuffer because the replace() method in String can only replace a character with another single character, and '' obviously counts as
two (which, formally, makes '' a String).
[ May 09, 2002: Message edited by: Val Pecaoco ]