request.querystring, all values if empty?

Discussion in 'ASP General' started by Kim, May 23, 2007.

  1. Kim

    Kim Guest

    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.
     
    Kim, May 23, 2007
    #1
    1. Advertising

  2. 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"
     
    Bob Barrows [MVP], May 23, 2007
    #2
    1. Advertising

  3. Kim

    Kim Guest

    > 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.
     
    Kim, May 23, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Bass
    Replies:
    2
    Views:
    3,778
    dave wanta
    Jul 4, 2003
  2. George
    Replies:
    5
    Views:
    6,684
    George
    Apr 2, 2004
  3. michaaal
    Replies:
    6
    Views:
    438
    Michael D. Kersey
    Jul 15, 2003
  4. John Davis
    Replies:
    2
    Views:
    427
    Dave Anderson
    Aug 18, 2003
  5. Ivan
    Replies:
    5
    Views:
    171
Loading...

Share This Page