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

How can I get through the "'"

P: n/a
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!
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200508/1
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies

P: n/a
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
Nov 21 '05 #2

P: n/a
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
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #3

P: n/a
Ivan,

Therefore are the parameters.
See this sample on our website.
http://www.windowsformsdatagridhelp....3-eb8b44af0137

It is with the Fill however I assume that you can translate it to an update.
An even simpler sample is on the site with SQL.

(The datetime is used because that is mostly the most awfull one if you are
not living in the USA)

I hope this helps,

Cor
Nov 21 '05 #4

P: n/a
Hi Cor, seems that's the not sample that I am looking for. By the way, thanks
a lot!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #5

P: n/a
Ivan V via DotNetMonster.com wrote:
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. :-)

--

(O) e n o n e
Nov 21 '05 #6

P: n/a
Thanks Oenone, it works well for me now. :-)
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.