How to pass special characters in Update stmt!!

J

Jay

Hello,

I need to use Update Sql stmt from my page.

Some of the field values has apostrophes and and quotes.

How do I make ado.net ignore those characters?
Eg-
UPDATE ROOM SET HEIGHT='3' - 5"' WHERE RMNU='100'


Iam using c#.

Thanks.
Jay
 
E

Erik Frey

SQL server string literals allow two single quotes (apostrophes) to
represent a single quote. Double quotes don't matter.

So your line should be:

UPDATE ROOM SET HEIGHT='3'' - 5"' WHERE RMNU='100'
 
N

Nedu N

Jay,

You can use paramers in the sql query and you can pass whatever the special
characters you want to pass into the SQL query without any problem.
Use SqlCommand or OleDBCommand object and use its parameters collection for
your where clause or SET clause.

Thanks
Nedu
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top