Connecting Tech Pros Worldwide Forums | Help | Site Map

Why is Request.QuerySting being treated as a number?

Jules
Guest
 
Posts: n/a
#1: Jul 19 '05
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
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Why is Request.QuerySting 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.rickards@ndm.gov.on.ca> wrote in message
news:f53140ee.0310070557.6b4623dc@posting.google.c om...[color=blue]
> 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[/color]


Aaron Bertrand - MVP
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Why is Request.QuerySting 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?


Bob Barrows
Guest
 
Posts: n/a
#4: Jul 19 '05

re: Why is Request.QuerySting 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.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[/color]


Julian Rickards
Guest
 
Posts: n/a
#5: Jul 19 '05

re: Why is Request.QuerySting being treated as a number?


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
Guest
 
Posts: n/a
#6: Jul 19 '05

re: Why is Request.QuerySting 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.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
Guest
 
Posts: n/a
#7: Jul 19 '05

re: Why is Request.QuerySting 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.QUERYSTRING("NRYEAR")
RESPONSE.END


Ray at work

"Julian Rickards" <julian.rickards@ndm.gov.on.ca> wrote in message
news:uDjOOYOjDHA.3192@TK2MSFTNGP11.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.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![/color]


Ray at
Guest
 
Posts: n/a
#8: Jul 19 '05

re: Why is Request.QuerySting 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:egDVkbOjDHA.2300@TK2MSFTNGP10.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.QUERYSTRING("NRYEAR")
> RESPONSE.END
>
>
> Ray at work
>
> "Julian Rickards" <julian.rickards@ndm.gov.on.ca> wrote in message
> news:uDjOOYOjDHA.3192@TK2MSFTNGP11.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.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):[/color][/color]


Don Verhagen
Guest
 
Posts: n/a
#9: Jul 19 '05

re: Why is Request.QuerySting being treated as a number?


In news:%235mmNYOjDHA.3192@TK2MSFTNGP11.phx.gbl,
Julian Rickards <julian.rickards@ndm.gov.on.ca> 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!


Bob Barrows
Guest
 
Posts: n/a
#10: Jul 19 '05

re: Why is Request.QuerySting 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.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![/color]


Hannibal
Guest
 
Posts: n/a
#11: Jul 19 '05

re: Why is Request.QuerySting 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@southeast-florida.com> wrote in message
news:blunrt$gj3tp$1@ID-181477.news.uni-berlin.de...[color=blue]
> In news:%235mmNYOjDHA.3192@TK2MSFTNGP11.phx.gbl,
> Julian Rickards <julian.rickards@ndm.gov.on.ca> 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[/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.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!
>
>[/color]


Guinness Mann
Guest
 
Posts: n/a
#12: Jul 19 '05

re: Why is Request.QuerySting being treated as a number?


In article <#5mmNYOjDHA.3192@TK2MSFTNGP11.phx.gbl>,
julian.rickards@ndm.gov.on.ca says...[color=blue]
> 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"[/color]

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

-- Rick

Julian Rickards
Guest
 
Posts: n/a
#13: Jul 19 '05

re: Why is Request.QuerySting 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.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!
Closed Thread


Similar ASP / Active Server Pages bytes