Querystring issue with the + sign separator

Discussion in 'ASP General' started by Simon Gare, Oct 23, 2007.

  1. Simon Gare

    Simon Gare Guest

    Hi All,

    I have a querystring that contains the + sign as a separator, I need to read
    these values individually in a select statement, for example.

    &text=Single+205

    where single is the type of room somebody wants and 205 is the user ID in
    the Customer table.

    Please help.

    Regards
    Simon
     
    Simon Gare, Oct 23, 2007
    #1
    1. Advertising

  2. "Simon Gare" <> wrote in message
    news:%...
    > Hi All,
    >
    > I have a querystring that contains the + sign as a separator, I need to

    read
    > these values individually in a select statement, for example.
    >
    > &text=Single+205
    >
    > where single is the type of room somebody wants and 205 is the user ID in
    > the Customer table.
    >
    > Please help.
    >


    I include the following for academic reasons.

    <do not use>
    The + will be considered an escape character for space hence the code:-

    Dim sText : sText = Request.QueryString("text")

    Will put the string "Single 205" in the variable sText. The split function
    can be used to get the separate values:-

    Dim asText : asText = Split(sText, " ")

    Now asText(0) is "Single" and asText(1) is "205"

    </do not use>

    However encoding two distinct pieces of data into a single value is not
    sensible. Better would be:-

    &type=Single&userid=205

    Now the code is:-

    Dim sType : sType = Request.QueryString("type")
    Dim lUserID : lUserID = CLng(Request.QueryString("userid")


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Oct 23, 2007
    #2
    1. Advertising

  3. Simon Gare

    Simon Gare Guest

    Anthony thanks for that will give it a go.

    Regards
    Simon
     
    Simon Gare, Oct 23, 2007
    #3
    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. Jimmy
    Replies:
    1
    Views:
    950
    Cowboy \(Gregory A. Beamer\)
    Nov 21, 2006
  2. David C

    Handle # sign in url/querystring

    David C, Apr 7, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    424
    Cowboy \(Gregory A. Beamer\)
    Apr 7, 2008
  3. King Coffee
    Replies:
    2
    Views:
    475
    King Coffee
    Dec 1, 2009
  4. Joey Martin

    Passing percent sign in querystring

    Joey Martin, Apr 22, 2005, in forum: ASP General
    Replies:
    11
    Views:
    1,639
    Bob Barrows [MVP]
    Apr 22, 2005
  5. Jimmy
    Replies:
    3
    Views:
    2,415
    shimmyshack
    Nov 20, 2006
Loading...

Share This Page