Why is Request.QuerySting being treated as a number?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jules

    Why is Request.QuerySting being treated as a number?

    Hi:

    I have the following:

    NRYear = Request.QuerySt ring("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.QuerySt ring as the user's
    selection.

    Help!!! Running out of ideas,

    Jules
  • Ray at

    #2
    Re: Why is Request.QuerySt ing being treated as a number?

    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" <julian.rickard s@ndm.gov.on.ca > wrote in message
    news:f53140ee.0 310070557.6b462 3dc@posting.goo gle.com...[color=blue]
    > Hi:
    >
    > I have the following:
    >
    > NRYear = Request.QuerySt ring("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.QuerySt ring as the user's
    > selection.
    >
    > Help!!! Running out of ideas,
    >
    > Jules[/color]


    Comment

    • Aaron Bertrand - MVP

      #3
      Re: Why is Request.QuerySt ing being treated as a number?

      > However, when I concatenate it with "1/1/", I get "1/1/+2003" as if[color=blue]
      > the NRYear is a number.[/color]

      Could you possibly show the code you are using to concatenate?


      Comment

      • Bob Barrows

        #4
        Re: Why is Request.QuerySt ing being treated as a number?

        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:[color=blue]
        > Hi:
        >
        > I have the following:
        >
        > NRYear = Request.QuerySt ring("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.QuerySt ring as the user's
        > selection.
        >
        > Help!!! Running out of ideas,
        >
        > Jules[/color]


        Comment

        • Julian Rickards

          #5
          Re: Why is Request.QuerySt ing being treated as a number?

          OK, here is the code:

          NRYear = Request.QuerySt ring("nryear")
          StartOfYear = "11/1/" & NRYear
          EndOfYear = "12/31/" & NRYear
          SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & " And "
          & EndOfYear

          Response.Write SQLWhereString

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

          newsreleases.nr date 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!

          Comment

          • Julian Rickards

            #6
            Re: Why is Request.QuerySt ing being treated as a number?

            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.QuerySt ring("nryear")
            StartOfYear = "1/1/" & NRYear
            EndOfYear = "12/31/" & NRYear
            SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & " And "
            & EndOfYear

            Response.Write SQLWhereString


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

            newsreleases.nr date 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!

            Comment

            • Ray at

              #7
              Re: Why is Request.QuerySt ing being treated as a number?

              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.QUERYST RING("NRYEAR")
              RESPONSE.END


              Ray at work

              "Julian Rickards" <julian.rickard s@ndm.gov.on.ca > wrote in message
              news:uDjOOYOjDH A.3192@TK2MSFTN GP11.phx.gbl...[color=blue]
              > 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.QuerySt ring("nryear")
              > StartOfYear = "1/1/" & NRYear
              > EndOfYear = "12/31/" & NRYear
              > SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & " And "
              > & EndOfYear
              >
              > Response.Write SQLWhereString
              >
              >
              > The output from the response.write is (copied and pasted exactly as
              > output):
              >
              > newsreleases.nr date 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![/color]


              Comment

              • Ray at

                #8
                Re: Why is Request.QuerySt ing being treated as a number?

                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:egDVkbOjDH A.2300@TK2MSFTN GP10.phx.gbl...[color=blue]
                > Well, your plus is in your querystring then. Your URL must look like[/color]
                this:[color=blue]
                >
                >
                > yoursite.com/page.asp?nryear =+2003 or yoursite.com/page.asp?nryear =%2B2003
                >
                > You'll see this if you do:
                >
                > RESPONSE.WRITE REQUEST.QUERYST RING("NRYEAR")
                > RESPONSE.END
                >
                >
                > Ray at work
                >
                > "Julian Rickards" <julian.rickard s@ndm.gov.on.ca > wrote in message
                > news:uDjOOYOjDH A.3192@TK2MSFTN GP11.phx.gbl...[color=green]
                > > 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.QuerySt ring("nryear")
                > > StartOfYear = "1/1/" & NRYear
                > > EndOfYear = "12/31/" & NRYear
                > > SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & " And "
                > > & EndOfYear
                > >
                > > Response.Write SQLWhereString
                > >
                > >
                > > The output from the response.write is (copied and pasted exactly as
                > > output):[/color][/color]


                Comment

                • Don Verhagen

                  #9
                  Re: Why is Request.QuerySt ing being treated as a number?

                  In news:%235mmNYOj DHA.3192@TK2MSF TNGP11.phx.gbl,
                  Julian Rickards <julian.rickard s@ndm.gov.on.ca > typed:
                  : OK, here is the code:
                  :
                  : NRYear = Request.QuerySt ring("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.n rdate Between " & StartOfYear & "
                  : And " & EndOfYear
                  :
                  : Response.Write SQLWhereString
                  :
                  : and the Response.Write spits out (exactly as pasted below):
                  :
                  : newsreleases.nr date 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!


                  Comment

                  • Bob Barrows

                    #10
                    Re: Why is Request.QuerySt ing being treated as a number?

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

                    Response.Write NRYear

                    Bob Barrows

                    Julian Rickards wrote:[color=blue]
                    > OK, here is the code:
                    >
                    > NRYear = Request.QuerySt ring("nryear")
                    > StartOfYear = "11/1/" & NRYear
                    > EndOfYear = "12/31/" & NRYear
                    > SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & "
                    > And " & EndOfYear
                    >
                    > Response.Write SQLWhereString
                    >
                    > and the Response.Write spits out (exactly as pasted below):
                    >
                    > newsreleases.nr date 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![/color]


                    Comment

                    • Hannibal

                      #11
                      Re: Why is Request.QuerySt ing being treated as a number?

                      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" <news@southea st-florida.com> wrote in message
                      news:blunrt$gj3 tp$1@ID-181477.news.uni-berlin.de...[color=blue]
                      > In news:%235mmNYOj DHA.3192@TK2MSF TNGP11.phx.gbl,
                      > Julian Rickards <julian.rickard s@ndm.gov.on.ca > typed:
                      > : OK, here is the code:
                      > :
                      > : NRYear = Request.QuerySt ring("nryear")
                      >
                      >
                      > Add a Response.Write ("NRYear = " & NRYear)
                      >
                      > To see what is actually in the QueryString. I think you are assuming it's[/color]
                      a[color=blue]
                      > concatination problem when it could very well be a data problem.
                      >
                      > Don
                      >
                      >
                      >
                      > : StartOfYear = "11/1/" & NRYear
                      > : EndOfYear = "12/31/" & NRYear
                      > : SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & "
                      > : And " & EndOfYear
                      > :
                      > : Response.Write SQLWhereString
                      > :
                      > : and the Response.Write spits out (exactly as pasted below):
                      > :
                      > : newsreleases.nr date 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!
                      >
                      >[/color]


                      Comment

                      • Guinness Mann

                        #12
                        Re: Why is Request.QuerySt ing being treated as a number?

                        In article <#5mmNYOjDHA.31 92@TK2MSFTNGP11 .phx.gbl>,
                        julian.rickards @ndm.gov.on.ca says...[color=blue]
                        > OK, here is the code:
                        >
                        > NRYear = Request.QuerySt ring("nryear")
                        > StartOfYear = "11/1/" & NRYear
                        > EndOfYear = "12/31/" & NRYear
                        > SQLWhereString = "newsreleases.n rdate Between " & StartOfYear & " And "
                        > & EndOfYear
                        >
                        > Response.Write SQLWhereString
                        >
                        > and the Response.Write spits out (exactly as pasted below):
                        >
                        > newsreleases.nr date Between 11/1/+2003" And 12/31/+2003"[/color]

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

                        -- Rick

                        Comment

                        • Julian Rickards

                          #13
                          Re: Why is Request.QuerySt ing being treated as a number?

                          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.QuerySt ring 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!

                          Comment

                          Working...