How to pass special characters in Update stmt!!

  • Thread starter Thread starter Jay
  • Start date Start date
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
 
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'
 
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
 
Back
Top