By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Replace problem

P: n/a
I am storing HTML in an oracle database, this is loaded from a textbox
in a webpage, I convert ' to ' ' using the code below:

foo.Replace("'", "''").Replace("&", "'||'&'||'")

this works just fine, then when I retrieve the text from the database
and display it in a webpage, I convert it back using:

objdr.Item("foo").Replace("''", "'").Replace("'||'&'||'", "&")

For some reason this then ends up converting ' ' not to ' but to an
upside down question mark , not sure of the correct terminology for
that.

Any thoughts on why it is doing this and how to prevent it?

Thanks in advance

Mar 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I'm not exactly sure what you're trying to do -- all your quotes are
running together. Are you trying to convert one single quote
(apostrophe) to two single quotes (two apostrophes) or one double quote
mark? Anyway, to get a double quote in VB you need to do (or can do)
this very strange thing.
dim strDoubleQuote as String
strDoubleQuote = """" ' 4 double quotes evaluates to a single
double quote.
strSingleQuote = "'" ' Apostrophe encased in double quotes.
Perhaps that will help you. Or you can use the CHR function with the
proper ASCII code for the quote you want.

So to replace singles by doubles do
foo = Replace(foo, strSingleQuote, strDoubleQuote)

Mar 28 '06 #2

P: n/a
Hi,

Actually I think I have an idea what AZNewsh is doing. He is using a
familiar technique to clean up his HTML before it enters the database.
Something similar to preventing SQL Injection, I think.

So, he is converting a single quote to 2 single quotes, and when
retrieving data back from the database, he is converting the 2 single
quotes back to a single quote.

Though I have no idea why he could be getting an "inverted question
mark" (Yes, that's what it's called, according to Charmap.)

Regards,

Cerebrus.

Mar 28 '06 #3

P: n/a
Correct that is exactly what I am trying to do, it works fine in so far
as it cleans up the quotes before entering the database. I have since
been informed that it doesn't actually replace with 2 single quotes,
just fools Oracle somehow, so i actually don't need to reverse it, it
does however even look like a an inverted question mark even in the
database when viewed through Toad, haven't tried SQL Plus but expect
the same, I did put a replace in place that will now convert the
inverted question mark back to an apostrophe, when selecting and this
works but seems like a rather none elegant solution

Any thoughts?

AZNewsh

Apr 3 '06 #4

P: n/a

"AZNewsh" <gn@dana.ucc.nau.edu> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Correct that is exactly what I am trying to do, it works fine in so far
as it cleans up the quotes before entering the database. I have since
been informed that it doesn't actually replace with 2 single quotes,
just fools Oracle somehow, so i actually don't need to reverse it, it
does however even look like a an inverted question mark even in the
database when viewed through Toad, haven't tried SQL Plus but expect
the same, I did put a replace in place that will now convert the
inverted question mark back to an apostrophe, when selecting and this
works but seems like a rather none elegant solution

Any thoughts?


ISTR that Oracle has weird notions about some characters, including
wildcards. It also has optional character map pages. Don't know if it helps.
Apr 6 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.