request.querystring, all values if empty?

request.querystring, all values if empty?

am 23.05.2007 12:49:19 von 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.

Re: request.querystring, all values if empty?

am 23.05.2007 13:09:40 von reb01501

Kim wrote:
> 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.

--
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"

Re: request.querystring, all values if empty?

am 23.05.2007 18:27:22 von 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.