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

    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 changes..it 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,



    Teena

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

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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...

    http://someapp.com/test.aspx?title=mytitle&quantity=45

    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

    http://someapp.com/test.aspx?title=p...il&quantity=45

    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
  •