Redirect with variable

A

alexz

I'm redirecting a value to a page called update.asp from somepage.asp

Recid = Request.QueryString("qryCategory")
Response.redirect "update.asp?" & Recid

So it shows like /update.asp?3


My question is how do i grab that value (3)
and then use it in a query.

Thanks
 
R

Rafael Chemtob

you would need to put the "3" in a querystring. So the redirect should go
to:
update.asp?ID=3
then to get the value of ID in the next page, you would use
abc = request.querystring ("ID")

good luck
 
E

Evertjan.

Rafael Chemtob wrote on 11 feb 2004 in
microsoft.public.inetserver.asp.general:
you would need to put the "3" in a querystring. So the redirect
should go to:
update.asp?ID=3
then to get the value of ID in the next page, you would use
abc = request.querystring ("ID")

It is the best way, but not "need"

update.asp?3

==========================

abc = request.querystring

gives as value for abc: 3
 
A

Alex zurab

Recid = Request.QueryString("qryCategory")
Response.redirect "update.asp?" & Recid

and then

StrRecid = Request.QueryString("rec")

works and i do get the value passed.
And the i get a new problem.

As a test i do have this working
rs.Source = "SELECT * FROM courseReg WHERE(((courseReg.CourseID)=3))"
line 24 rs.CursorLocation = 2
line 25 rs.LockType = 3
line 26 rs.Open()

But when i try

rs.Source = "SELECT * FROM courseReg WHERE (((courseReg.CourseID) = " &
StrRecid & ")) "
rs.CursorType = 0

Microsoft JET Database Engine error '80040e14'
Extra ) in query expression '(((courseReg.CourseID) = ))'.
update.asp, line 26

I know i pass the correct value i just don't understand
why this code giving problems.
 
B

Bob Barrows [MVP]

Alex said:
rs.Source = "SELECT * FROM courseReg WHERE (((courseReg.CourseID) = "
& StrRecid & ")) "
rs.CursorType = 0

Microsoft JET Database Engine error '80040e14'
Extra ) in query expression '(((courseReg.CourseID) = ))'.
update.asp, line 26

I know i pass the correct value i just don't understand
why this code giving problems.

It's pretty obvious that StrRecid does not contain what you think it
contains. And here is why:
Recid = Request.QueryString("qryCategory")
Response.redirect "update.asp?" & Recid

You did not name the querystring variable in the redirect statement. It
should be:
Response.redirect "update.asp?rec=" & Recid


To help you better debug these things, never assign a concatenated string
directly to an object's property. Always assign it to a variable, and
subsequently use the variable in the code. This will allow you to write the
variable to the response to see what it contains. Like this (I'm getting rid
of those unneeded and confusing parentheses):

sSQL="SELECT * FROM courseReg WHERE courseReg.CourseID = "
sSQL = sSQL & StrRecid
'the following lines can be commented or deleted after debugging is done
'*******************************************
Response.Write sSQL
Response.End
'*******************************************
'it looks like you are opening a default cursor, so only one
'line is needed (you don't even need the "set rs=createobject" line):
set rs = conn.execute(sSQL,,1)

You only need to explicitly create and set the recordset's properties if you
need something other than the default, server-side, forward-only cursor.

HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top