How can I get through the "'"

  • Thread starter Thread starter Ivan V via DotNetMonster.com
  • Start date Start date
I

Ivan V via DotNetMonster.com

Dear All:

I got a problem a savinf problem about my data into sql server. If the
remarks filed include the "'" such as Chan's, Int'L, an error message will
pop up whixh is caused by the "'", anyone knows I can get this through???
Thanks!
 
Ivan,

I assume that you are not typing it directly into the SQL server, therefore
how do you do it.

In other words, what classes are you using, how does your insertstring look
like.

Cor
 
Hi Cor, thanks for that reply, in my case, for instance, in a taxt box, there
is a name "INT'L" in it and i am using sql command "insert into" and that's
where my problem appeared!

Ivan
 
Hi Cor, seems that's the not sample that I am looking for. By the way, thanks
a lot!
 
Ivan said:
I got a problem a savinf problem about my data into sql server.
If the remarks filed include the "'" such as Chan's, Int'L, an error
message will pop up whixh is caused by the "'", anyone knows I can
get this through???

Replace each single-quote character with two single-quote characters in your
string, e.g.:

\\\
sql = "INSERT INTO YourTable "
sql &= "VALUES ('" & Replace(YourValue, "'", "''") & "')"
///

When SQL Server sees two single-quotes within a quoted string, it will
interpret them as a single single-quote within the value.

Hope that makes sense. :-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top