Why is Request.QuerySting being treated as a number?

Discussion in 'ASP General' started by Jules, Oct 7, 2003.

  1. Jules

    Jules Guest

    Hi:

    I have the following:

    NRYear = Request.QueryString("nryear")

    which I assumed would result in NRYear containing a string.

    However, when I concatenate it with "1/1/", I get "1/1/+2003" as if
    the NRYear is a number.

    Ultimately, this will go in a SQL string such as

    SQL = "Select * from newsreleases where nrdate between 1/1/2003 and
    12/31/2003;"

    and I want the year to come from the Request.QueryString as the user's
    selection.

    Help!!! Running out of ideas,

    Jules
    Jules, Oct 7, 2003
    #1
    1. Advertising

  2. Jules

    Ray at Guest

    And how are you concatenating? You're apparently also concatenating a "+"
    in there. Either that, or the + is in your querystring value.

    Ray at work

    "Jules" <> wrote in message
    news:...
    > Hi:
    >
    > I have the following:
    >
    > NRYear = Request.QueryString("nryear")
    >
    > which I assumed would result in NRYear containing a string.
    >
    > However, when I concatenate it with "1/1/", I get "1/1/+2003" as if
    > the NRYear is a number.
    >
    > Ultimately, this will go in a SQL string such as
    >
    > SQL = "Select * from newsreleases where nrdate between 1/1/2003 and
    > 12/31/2003;"
    >
    > and I want the year to come from the Request.QueryString as the user's
    > selection.
    >
    > Help!!! Running out of ideas,
    >
    > Jules
    Ray at, Oct 7, 2003
    #2
    1. Advertising

  3. > However, when I concatenate it with "1/1/", I get "1/1/+2003" as if
    > the NRYear is a number.


    Could you possibly show the code you are using to concatenate?
    Aaron Bertrand - MVP, Oct 7, 2003
    #3
  4. Jules

    Bob Barrows Guest

    That does not happen to me.

    sYear = "2003"
    Response.write "1/1" & sYear

    results in the expected "1/1/2003"

    Please show us how to reproduce your problem.

    Bob Barrows

    Jules wrote:
    > Hi:
    >
    > I have the following:
    >
    > NRYear = Request.QueryString("nryear")
    >
    > which I assumed would result in NRYear containing a string.
    >
    > However, when I concatenate it with "1/1/", I get "1/1/+2003" as if
    > the NRYear is a number.
    >
    > Ultimately, this will go in a SQL string such as
    >
    > SQL = "Select * from newsreleases where nrdate between 1/1/2003 and
    > 12/31/2003;"
    >
    > and I want the year to come from the Request.QueryString as the user's
    > selection.
    >
    > Help!!! Running out of ideas,
    >
    > Jules
    Bob Barrows, Oct 7, 2003
    #4
  5. OK, here is the code:

    NRYear = Request.QueryString("nryear")
    StartOfYear = "11/1/" & NRYear
    EndOfYear = "12/31/" & NRYear
    SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & " And "
    & EndOfYear

    Response.Write SQLWhereString

    and the Response.Write spits out (exactly as pasted below):

    newsreleases.nrdate Between 11/1/+2003" And 12/31/+2003"


    I am building a search form where the user selects the year and I am
    trying to build a between clause from the year selected.

    Jules

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Julian Rickards, Oct 7, 2003
    #5
  6. HI:

    I hope this isn't being double posted - I tried to post a response
    directly to DevDex but it hasn't appeared after about 30 minutes of
    waiting.

    OK, here is the code:

    NRYear = Request.QueryString("nryear")
    StartOfYear = "1/1/" & NRYear
    EndOfYear = "12/31/" & NRYear
    SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & " And "
    & EndOfYear

    Response.Write SQLWhereString


    The output from the response.write is (copied and pasted exactly as
    output):

    newsreleases.nrdate Between 1/1/+2003" And 12/31/+2003"

    So, as you can see, there is a plus (+) at the beginning and a double
    quote at the end of each NRYear.

    Jules

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Julian Rickards, Oct 7, 2003
    #6
  7. Jules

    Ray at Guest

    Well, your plus is in your querystring then. Your URL must look like this:


    yoursite.com/page.asp?nryear=+2003 or yoursite.com/page.asp?nryear=%2B2003

    You'll see this if you do:

    RESPONSE.WRITE REQUEST.QUERYSTRING("NRYEAR")
    RESPONSE.END


    Ray at work

    "Julian Rickards" <> wrote in message
    news:...
    > HI:
    >
    > I hope this isn't being double posted - I tried to post a response
    > directly to DevDex but it hasn't appeared after about 30 minutes of
    > waiting.
    >
    > OK, here is the code:
    >
    > NRYear = Request.QueryString("nryear")
    > StartOfYear = "1/1/" & NRYear
    > EndOfYear = "12/31/" & NRYear
    > SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & " And "
    > & EndOfYear
    >
    > Response.Write SQLWhereString
    >
    >
    > The output from the response.write is (copied and pasted exactly as
    > output):
    >
    > newsreleases.nrdate Between 1/1/+2003" And 12/31/+2003"
    >
    > So, as you can see, there is a plus (+) at the beginning and a double
    > quote at the end of each NRYear.
    >
    > Jules
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Ray at, Oct 7, 2003
    #7
  8. Jules

    Ray at Guest

    Oh, and also the quote is in your querystring too. I forgot about that
    part.

    Ray at work

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > Well, your plus is in your querystring then. Your URL must look like

    this:
    >
    >
    > yoursite.com/page.asp?nryear=+2003 or yoursite.com/page.asp?nryear=%2B2003
    >
    > You'll see this if you do:
    >
    > RESPONSE.WRITE REQUEST.QUERYSTRING("NRYEAR")
    > RESPONSE.END
    >
    >
    > Ray at work
    >
    > "Julian Rickards" <> wrote in message
    > news:...
    > > HI:
    > >
    > > I hope this isn't being double posted - I tried to post a response
    > > directly to DevDex but it hasn't appeared after about 30 minutes of
    > > waiting.
    > >
    > > OK, here is the code:
    > >
    > > NRYear = Request.QueryString("nryear")
    > > StartOfYear = "1/1/" & NRYear
    > > EndOfYear = "12/31/" & NRYear
    > > SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & " And "
    > > & EndOfYear
    > >
    > > Response.Write SQLWhereString
    > >
    > >
    > > The output from the response.write is (copied and pasted exactly as
    > > output):
    Ray at, Oct 7, 2003
    #8
  9. Jules

    Bob Barrows Guest

    As Ray suggested, show us what you get when you do this:

    Response.Write NRYear

    Bob Barrows

    Julian Rickards wrote:
    > OK, here is the code:
    >
    > NRYear = Request.QueryString("nryear")
    > StartOfYear = "11/1/" & NRYear
    > EndOfYear = "12/31/" & NRYear
    > SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & "
    > And " & EndOfYear
    >
    > Response.Write SQLWhereString
    >
    > and the Response.Write spits out (exactly as pasted below):
    >
    > newsreleases.nrdate Between 11/1/+2003" And 12/31/+2003"
    >
    >
    > I am building a search form where the user selects the year and I am
    > trying to build a between clause from the year selected.
    >
    > Jules
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Bob Barrows, Oct 7, 2003
    #9
  10. Jules

    Don Verhagen Guest

    In news:%,
    Julian Rickards <> typed:
    : OK, here is the code:
    :
    : NRYear = Request.QueryString("nryear")


    Add a Response.Write ("NRYear = " & NRYear)

    To see what is actually in the QueryString. I think you are assuming it's a
    concatination problem when it could very well be a data problem.

    Don



    : StartOfYear = "11/1/" & NRYear
    : EndOfYear = "12/31/" & NRYear
    : SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & "
    : And " & EndOfYear
    :
    : Response.Write SQLWhereString
    :
    : and the Response.Write spits out (exactly as pasted below):
    :
    : newsreleases.nrdate Between 11/1/+2003" And 12/31/+2003"
    :
    :
    : I am building a search form where the user selects the year and I am
    : trying to build a between clause from the year selected.
    :
    : Jules
    :
    : *** Sent via Developersdex http://www.developersdex.com ***
    : Don't just participate in USENET...get rewarded for it!
    Don Verhagen, Oct 7, 2003
    #10
  11. Jules

    Hannibal Guest

    naaa, i suspect that NRYear is coming through with the +
    Why don't you copy the url(that is, the pagename and everything after) for
    us and paste it here...


    "Don Verhagen" <> wrote in message
    news:blunrt$gj3tp$-berlin.de...
    > In news:%,
    > Julian Rickards <> typed:
    > : OK, here is the code:
    > :
    > : NRYear = Request.QueryString("nryear")
    >
    >
    > Add a Response.Write ("NRYear = " & NRYear)
    >
    > To see what is actually in the QueryString. I think you are assuming it's

    a
    > concatination problem when it could very well be a data problem.
    >
    > Don
    >
    >
    >
    > : StartOfYear = "11/1/" & NRYear
    > : EndOfYear = "12/31/" & NRYear
    > : SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & "
    > : And " & EndOfYear
    > :
    > : Response.Write SQLWhereString
    > :
    > : and the Response.Write spits out (exactly as pasted below):
    > :
    > : newsreleases.nrdate Between 11/1/+2003" And 12/31/+2003"
    > :
    > :
    > : I am building a search form where the user selects the year and I am
    > : trying to build a between clause from the year selected.
    > :
    > : Jules
    > :
    > : *** Sent via Developersdex http://www.developersdex.com ***
    > : Don't just participate in USENET...get rewarded for it!
    >
    >
    Hannibal, Oct 7, 2003
    #11
  12. In article <#>,
    says...
    > OK, here is the code:
    >
    > NRYear = Request.QueryString("nryear")
    > StartOfYear = "11/1/" & NRYear
    > EndOfYear = "12/31/" & NRYear
    > SQLWhereString = "newsreleases.nrdate Between " & StartOfYear & " And "
    > & EndOfYear
    >
    > Response.Write SQLWhereString
    >
    > and the Response.Write spits out (exactly as pasted below):
    >
    > newsreleases.nrdate Between 11/1/+2003" And 12/31/+2003"


    Sounds to me like NRYear is " 2003", not "2003".

    -- Rick
    Guinness Mann, Oct 7, 2003
    #12
  13. OK, I have figured it out but it was something I would never have
    suspected.

    The year was coming from a select list on the search page which was
    generated by a for loop:

    currentyear = Right(Date, 4)
    for i=2000 to currentyear
    Response.write "<option value=" & chr(34) & i & chr(34) & ">" & i
    next


    The variable "i" was being used by the for loop presumably as a number
    so that it may be incremented.

    When a year is selected, it is added to the QueryString as nryear=2003.
    Because my book (a poor one but all I have) tells me that
    Request.QueryString will bring in 2003 as a string, I didn't think it
    had to be converted from a number into a string but for some reason,
    because currentyear is a number, it seems that the numeric property of
    nryear was being carried through.

    When I changed the currentyear statement to

    currentyear = Right(CStr(Date), 4)

    all the problems cleared up.

    Yes, the problem was in the query string but appears to be a function of
    the property of nryear when the option loop was being generated.

    Thanks for your help,

    Jules

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Julian Rickards, Oct 7, 2003
    #13
    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. Jim Heavey
    Replies:
    1
    Views:
    357
    Oisín Grehan
    Dec 2, 2003
  2. Dmitriy Zakharov
    Replies:
    2
    Views:
    421
    Dmitriy Zakharov
    Jul 30, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,661
    Smokey Grindel
    Dec 2, 2006
  4. JJ

    URL in a querysting?

    JJ, May 11, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    308
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Aug 9, 2007
  5. Irmen de Jong
    Replies:
    7
    Views:
    340
    Irmen de Jong
    Dec 7, 2011
Loading...

Share This Page