Results 1 to 3 of 3
  1. #1
    Join Date
    May 2011

    Unanswered: Problem with '&' character, not able to update ID in SQL table from front end

    Hi all,

    In my code, i have a ProductID which contains '&' character like "pen&pencil".I tried to update this as "pen&paper" from front end into database.But,database doesn't accept this remains as "pen&pencil"..Actually,I have created stored procedure for "update" and calling that in my code behind file.From front-end form , i'm entering new value and trying to update it. My code for update is as below -

    @ProductID char(15),

    @NewProductID char(15) = NULL,

    Update ProductTable SET ProductID = @NewProductID WHERE ProductID = @ProductID

    Please help me out.

    Thanks in advance,


  2. #2
    Join Date
    Jan 2003
    Provided Answers: 17
    You may need to escape the '&' character. In most languages, it would appear as "pen\&paper".

  3. #3
    Join Date
    Nov 2003
    Christchurch, New Zealand
    Code behind sounds like you are talking about ASP.Net. Assuming this is the case you are probably passing "pen&pencil" in the querystring.

    For query strings "&" is a reserved token in that it is used to separate values eg. a query string looks like...

    So if you break it up you get a title field with the value mytitle and a quantity field with 45.

    If you look at you example you will have something like

    So you would have a title field with pen and a quantity field with 45.

    To get around this you need to use URL encoding on your values. With will change the "&" into a character sequence that is used to represent the value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts