Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default QueryString query

    If Request.QueryString("StartLName") <> "" Then
    RecordToEdit = Request.QueryString("MemID")
    SQL = "SELECT * FROM member WHERE (LName Like
    '"&request.querystring("StartLName")&"');"
    End If

    <a href='listMemberSpec.asp?StartLName="A"'>A</A>

    I have this code (above), and I'd like to pass a letter (IE A) to StartLName
    with the * (Access DB) to retrieve all the Last Name records in the database
    that start with A

    Can anyone tell me please what part of the code I need to change in order to
    do this please?

    TIA


    RH Guest

  2. Similar Questions and Discussions

    1. QueryString Length
      method=post doesn't use the querystring. Your querystring length will be 0, unless you've put something your form action, like...
    2. QueryString MAx Length
      All, How can I find the Max length of the QueryString? I am passing data between ASP pages and use the Response.QueryString (I know that this is...
    3. how to pass an access DB query onto *next* page? trouble with *next* and *previous* querystring code
      Don;t see any sign of any paging code is your snippets normally take this form Set rso = Server.CreateObject("ADODB.Recordset") rso.PageSize =...
    4. querystring question
      "Gonzosez" wrote ... I dont think you need to, I believe that its only whilst the info travels through cyberspace and arrives at its...
    5. Pack QueryString
      I've got a (probably) long list of data which I want to send to an ASPX page by query string. To keep the URL short and compact I want to compress...
  3. #2

    Default Re: QueryString query

    RH wrote:
    > If Request.QueryString("StartLName") <> "" Then
    > RecordToEdit = Request.QueryString("MemID")
    > SQL = "SELECT * FROM member WHERE (LName Like
    > '"&request.querystring("StartLName")&"');"
    > End If
    >
    > <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    >
    > I have this code (above), and I'd like to pass a letter (IE A) to
    > StartLName with the * (Access DB) to retrieve all the Last Name
    > records in the database that start with A
    >
    > Can anyone tell me please what part of the code I need to change in
    > order to do this please?
    >
    > TIA
    Use a wildcard:


    " ... WHERE (LName Like '" & _
    request.querystring("StartLName") & "%');"

    Bob Barrows


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

  4. #3

    Default Re: QueryString query

    Hi Bob - thanks - but this doesn't seem to work.
    Is this the right wildcard for an Access 2003 DB?

    Robyn


    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OVIivLQ9DHA.3012@TK2MSFTNGP09.phx.gbl...
    > RH wrote:
    > > If Request.QueryString("StartLName") <> "" Then
    > > RecordToEdit = Request.QueryString("MemID")
    > > SQL = "SELECT * FROM member WHERE (LName Like
    > > '"&request.querystring("StartLName")&"');"
    > > End If
    > >
    > > <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    > >
    > > I have this code (above), and I'd like to pass a letter (IE A) to
    > > StartLName with the * (Access DB) to retrieve all the Last Name
    > > records in the database that start with A
    > >
    > > Can anyone tell me please what part of the code I need to change in
    > > order to do this please?
    > >
    > > TIA
    >
    > Use a wildcard:
    >
    >
    > " ... WHERE (LName Like '" & _
    > request.querystring("StartLName") & "%');"
    >
    > Bob Barrows
    >
    >
    > --
    > 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"
    >
    >

    RH Guest

  5. #4

    Default Re: QueryString query

    I added this :
    WHERE (LName Like '" & request.querystring("StartLName") & "%');"
    and this comes up
    listMemberSpec.asp?StartLName="A"
    How do I get the % next to the A?
    R

    "RH" <rh@rh.com> wrote in message
    news:ee8w$RQ9DHA.2412@TK2MSFTNGP09.phx.gbl...
    > Hi Bob - thanks - but this doesn't seem to work.
    > Is this the right wildcard for an Access 2003 DB?
    >
    > Robyn
    >
    >
    > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:OVIivLQ9DHA.3012@TK2MSFTNGP09.phx.gbl...
    > > RH wrote:
    > > > If Request.QueryString("StartLName") <> "" Then
    > > > RecordToEdit = Request.QueryString("MemID")
    > > > SQL = "SELECT * FROM member WHERE (LName Like
    > > > '"&request.querystring("StartLName")&"');"
    > > > End If
    > > >
    > > > <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    > > >
    > > > I have this code (above), and I'd like to pass a letter (IE A) to
    > > > StartLName with the * (Access DB) to retrieve all the Last Name
    > > > records in the database that start with A
    > > >
    > > > Can anyone tell me please what part of the code I need to change in
    > > > order to do this please?
    > > >
    > > > TIA
    > >
    > > Use a wildcard:
    > >
    > >
    > > " ... WHERE (LName Like '" & _
    > > request.querystring("StartLName") & "%');"
    > >
    > > Bob Barrows
    > >
    > >
    > > --
    > > 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"
    > >
    > >
    >
    >

    RH Guest

  6. #5

    Default Re: QueryString query

    What does "doesn't seem to work" mean? Error message? Incorrect result?

    Print out your sql statement:

    Response.Write SQL

    and make sure it's correct.

    FWIW, if you created the query in Access, you would use * for the wildcard.
    But when you build and run the query via ADO, you have to use the ODBC
    wildcard: %

    RH wrote:
    > Hi Bob - thanks - but this doesn't seem to work.
    > Is this the right wildcard for an Access 2003 DB?
    >
    > Robyn
    >
    >
    > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:OVIivLQ9DHA.3012@TK2MSFTNGP09.phx.gbl...
    >> RH wrote:
    >>> If Request.QueryString("StartLName") <> "" Then
    >>> RecordToEdit = Request.QueryString("MemID")
    >>> SQL = "SELECT * FROM member WHERE (LName Like
    >>> '"&request.querystring("StartLName")&"');"
    >>> End If
    >>>
    >>> <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    >>>
    >>> I have this code (above), and I'd like to pass a letter (IE A) to
    >>> StartLName with the * (Access DB) to retrieve all the Last Name
    >>> records in the database that start with A
    >>>
    >>> Can anyone tell me please what part of the code I need to change in
    >>> order to do this please?
    >>>
    >>> TIA
    >>
    >> Use a wildcard:
    >>
    >>
    >> " ... WHERE (LName Like '" & _
    >> request.querystring("StartLName") & "%');"
    >>

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

  7. #6

    Default Re: QueryString query

    RH wrote:
    > I added this :
    > WHERE (LName Like '" & request.querystring("StartLName") & "%');"
    > and this comes up
    > listMemberSpec.asp?StartLName="A"
    > How do I get the % next to the A?
    > R
    You don't. You pass the letter alone in the querystring. You append the % in
    the statement where you build the query.

    Wait a minute. Back up. Why do you want to put the % in the querystring?

    Bob Barrows

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

  8. #7

    Default Re: QueryString query

    Changed this:
    WHERE (LName Like '" & request.querystring("StartLName") & "%');"
    to this:
    WHERE (LName Like '" & request.querystring("StartLName") & "*');"

    SQL Statement comes out like this:
    SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like '"A"*');

    If I do this:
    SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    'Rice');"
    SQL statement comes out as:
    SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like 'Rice');
    and Rice, Terri is displayed.

    But if I want all the records starting with R and do this
    SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    'R*');"
    SQL statement comes out as:
    SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like 'R*');

    and no records are displayed - agggggg



    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OfRUkXQ9DHA.3364@TK2MSFTNGP09.phx.gbl...
    > What does "doesn't seem to work" mean? Error message? Incorrect result?
    >
    > Print out your sql statement:
    >
    > Response.Write SQL
    >
    > and make sure it's correct.
    >
    > FWIW, if you created the query in Access, you would use * for the
    wildcard.
    > But when you build and run the query via ADO, you have to use the ODBC
    > wildcard: %
    >
    > RH wrote:
    > > Hi Bob - thanks - but this doesn't seem to work.
    > > Is this the right wildcard for an Access 2003 DB?
    > >
    > > Robyn
    > >
    > >
    > > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > > news:OVIivLQ9DHA.3012@TK2MSFTNGP09.phx.gbl...
    > >> RH wrote:
    > >>> If Request.QueryString("StartLName") <> "" Then
    > >>> RecordToEdit = Request.QueryString("MemID")
    > >>> SQL = "SELECT * FROM member WHERE (LName Like
    > >>> '"&request.querystring("StartLName")&"');"
    > >>> End If
    > >>>
    > >>> <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    > >>>
    > >>> I have this code (above), and I'd like to pass a letter (IE A) to
    > >>> StartLName with the * (Access DB) to retrieve all the Last Name
    > >>> records in the database that start with A
    > >>>
    > >>> Can anyone tell me please what part of the code I need to change in
    > >>> order to do this please?
    > >>>
    > >>> TIA
    > >>
    > >> Use a wildcard:
    > >>
    > >>
    > >> " ... WHERE (LName Like '" & _
    > >> request.querystring("StartLName") & "%');"
    > >>
    >
    >
    > --
    > 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"
    >
    >

    RH Guest

  9. #8

    Default Re: QueryString query

    RH wrote:
    > Changed this:
    > WHERE (LName Like '" & request.querystring("StartLName") & "%');"
    > to this:
    > WHERE (LName Like '" & request.querystring("StartLName") & "*');"
    Why???
    >
    > SQL Statement comes out like this:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    > '"A"*');
    That's not right. You got this from a Response.Write?

    If request.querystring("StartLName") contains only the letter R, I would
    expect your above statement to result in:

    SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    'A*');

    But that's neither here nor there. This is the statement you should be
    striving for:

    SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    'A%');

    >
    > If I do this:
    > SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName
    > Like 'Rice');"
    > SQL statement comes out as:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    > 'Rice'); and Rice, Terri is displayed.
    As expected.
    >
    > But if I want all the records starting with R and do this
    > SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName
    > Like 'R*');"
    > SQL statement comes out as:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    > 'R*');
    >
    > and no records are displayed - agggggg
    >
    They're not supposed to! * is not a wildcard when running a query from ADO:
    it's a literal character. You're query is not finding any records where
    LName contains only the two characters R and *.

    Again. The % is the wildcard you need to use in ADO. Why are you ignoring
    this?

    SQL = "SELECT MemID, Chapter, Lname, Fname " & _
    "FROM member WHERE LName Like 'R%'"

    If you opened your database in Access and create a query, you would need to
    use the * as the wildcard. But when you create and run the query from ADO,
    you need to use %. I don't know how I can say this any plainer ...


    Bob Barrows


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

  10. #9

    Default Re: QueryString query

    Ok - I figured it out - the problem was with the
    <a href='listMemberSpec.asp?StartLName="A"'>A</A>

    s/b <a href='listMemberSpec.asp?StartLName=A'>A</A>

    Thanks for all your help!!!

    Robyn

    "RH" <rh@rh.com> wrote in message
    news:OY7XigQ9DHA.1636@TK2MSFTNGP12.phx.gbl...
    > Changed this:
    > WHERE (LName Like '" & request.querystring("StartLName") & "%');"
    > to this:
    > WHERE (LName Like '" & request.querystring("StartLName") & "*');"
    >
    > SQL Statement comes out like this:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like '"A"*');
    >
    > If I do this:
    > SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    > 'Rice');"
    > SQL statement comes out as:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like 'Rice');
    > and Rice, Terri is displayed.
    >
    > But if I want all the records starting with R and do this
    > SQL = "SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like
    > 'R*');"
    > SQL statement comes out as:
    > SELECT MemID, Chapter, Lname, Fname FROM member WHERE (LName Like 'R*');
    >
    > and no records are displayed - agggggg
    >
    >
    >
    > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:OfRUkXQ9DHA.3364@TK2MSFTNGP09.phx.gbl...
    > > What does "doesn't seem to work" mean? Error message? Incorrect result?
    > >
    > > Print out your sql statement:
    > >
    > > Response.Write SQL
    > >
    > > and make sure it's correct.
    > >
    > > FWIW, if you created the query in Access, you would use * for the
    > wildcard.
    > > But when you build and run the query via ADO, you have to use the ODBC
    > > wildcard: %
    > >
    > > RH wrote:
    > > > Hi Bob - thanks - but this doesn't seem to work.
    > > > Is this the right wildcard for an Access 2003 DB?
    > > >
    > > > Robyn
    > > >
    > > >
    > > > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > > > news:OVIivLQ9DHA.3012@TK2MSFTNGP09.phx.gbl...
    > > >> RH wrote:
    > > >>> If Request.QueryString("StartLName") <> "" Then
    > > >>> RecordToEdit = Request.QueryString("MemID")
    > > >>> SQL = "SELECT * FROM member WHERE (LName Like
    > > >>> '"&request.querystring("StartLName")&"');"
    > > >>> End If
    > > >>>
    > > >>> <a href='listMemberSpec.asp?StartLName="A"'>A</A>
    > > >>>
    > > >>> I have this code (above), and I'd like to pass a letter (IE A) to
    > > >>> StartLName with the * (Access DB) to retrieve all the Last Name
    > > >>> records in the database that start with A
    > > >>>
    > > >>> Can anyone tell me please what part of the code I need to change in
    > > >>> order to do this please?
    > > >>>
    > > >>> TIA
    > > >>
    > > >> Use a wildcard:
    > > >>
    > > >>
    > > >> " ... WHERE (LName Like '" & _
    > > >> request.querystring("StartLName") & "%');"
    > > >>
    > >
    > >
    > > --
    > > 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"
    > >
    > >
    >
    >

    RH Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139