How to pass special characters in Update stmt!!

Discussion in 'ASP .Net' started by Jay, Oct 30, 2003.

  1. Jay

    Jay Guest

    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
     
    Jay, Oct 30, 2003
    #1
    1. Advertising

  2. Jay

    Erik Frey Guest

    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" <> wrote in message
    news:...
    >
    > 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
    >
    >
    >
     
    Erik Frey, Oct 30, 2003
    #2
    1. Advertising

  3. Jay

    Nedu N Guest

    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


    "Jay" <> wrote in message
    news:...
    >
    > 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
    >
    >
    >
     
    Nedu N, Oct 30, 2003
    #3
  4. Jay

    William Ryan Guest

    I second that...params are better in every regard that I can think of.
    "Nedu N" <> wrote in message
    news:...
    > 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
    >
    >
    > "Jay" <> wrote in message
    > news:...
    > >
    > > 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
    > >
    > >
    > >

    >
    >
     
    William Ryan, Oct 31, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    3
    Views:
    33,307
    Stefan Mueller
    Jul 23, 2006
  2. Replies:
    2
    Views:
    297
  3. Replies:
    2
    Views:
    1,139
    Ingo Menger
    May 31, 2007
  4. rvino
    Replies:
    0
    Views:
    4,720
    rvino
    Aug 14, 2007
  5. Sobin Thomas
    Replies:
    5
    Views:
    850
    Mike Brind [MVP]
    May 21, 2008
Loading...

Share This Page