request.querystring, all values if empty?

K

Kim

How do I get all walues if my querystring is empty?
If I have a table with let's say 10 rows/records, (ID 1-10). I then have a
recordset with request.querystring("id") and get the record having the id
thats shown in the address bar ("..com?id=4" would get the record with the
id 4). How do I get all records if the querystring is empty ("..com")

I have:

<%
Dim rs_yadayada
rs_yadayada= "1"
If (request.querystring("id") <> "") Then
rs_yadayada= request.querystring("id")
End If
%>

and in the sql: ...WHERE id = " + Replace(rs_yadayada__id, "'", "''")


-but doesn't get me anything if the querystring is empty. Tried changing the
"1" to wildcards, arrays (1-10),.. but nope, I'm too dumb to figure this
out.
 
B

Bob Barrows [MVP]

Kim said:
How do I get all walues if my querystring is empty?
If I have a table with let's say 10 rows/records, (ID 1-10). I then
have a recordset with request.querystring("id") and get the record
having the id thats shown in the address bar ("..com?id=4" would get
the record with the id 4). How do I get all records if the
querystring is empty ("..com")
I have:

<%
Dim rs_yadayada
rs_yadayada= "1"
If (request.querystring("id") <> "") Then
rs_yadayada= request.querystring("id")
End If
%>

and in the sql: ...WHERE id = " + Replace(rs_yadayada__id, "'", "''")


-but doesn't get me anything if the querystring is empty. Tried
changing the "1" to wildcards, arrays (1-10),.. but nope, I'm too
dumb to figure this out.

If you want to retrieve all the records in a table, what sql statement would
you write? Write it down. Got it? Now, in your code, check to see if the
quertystring variable is empty. If it is empty, use the sql statement you
just wrote down instead of building one with a where clause.
 
K

Kim

If you want to retrieve all the records in a table, what sql statement
would you write? Write it down. Got it? Now, in your code, check to see if
the quertystring variable is empty. If it is empty, use the sql statement
you just wrote down instead of building one with a where clause.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Thanks, got it.
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top