Development ASP querystring database query

Discussion in 'Software' started by pritsey, 28 Dec 2006.

  1. pritsey

    pritsey Minimodder

    Joined:
    26 Nov 2002
    Posts:
    276
    Likes Received:
    0
    Hi all,

    After some help please with asp pages and query string. I have an access db on my server which I want to be able to query using an A-Z list at top of a page. This is where you click on A (for example) and then the asp page will query the database using 'A' as the driver (eg WHERE field LIKE 'A%' etc)...

    Instead of creating 26 different pages with a slightly different query in each, I'd like to pass a variable from the initial page to a single search asp page and the query takes the variable from the querystring - hope this is making sense!!!

    Basically, I know what I want to do, but not quite sure how to accomplish it.

    My code looks like the below at present:

    <%
    accessdb=server.mappath("\private\Courses.mdb")
    mySQL="SELECT Courses.Company, Courses.[Address 1] FROM Courses WHERE Company LIKE 'A%'"

    strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
    strconn=strconn & accessDB & ";"
    'strconn=strconn & "USER ID=;PASSWORD=;"

    call query2table(mySQL,strconn)
    %>

    Many thanks in advance!
     
  2. eek

    eek CAMRA ***.

    Joined:
    23 Jan 2002
    Posts:
    1,600
    Likes Received:
    14
    Pass the letter through in the query string (www.example.com/?l=a)

    Then you can just append it to the query string...
    Code:
    mySQL="SELECT Courses.Company, Courses.[Address 1] FROM Courses WHERE Company LIKE '" & Request.QueryString("l") & "%'"
     
  3. pritsey

    pritsey Minimodder

    Joined:
    26 Nov 2002
    Posts:
    276
    Likes Received:
    0
    eek - thanks! Works a treat. I was messing around with loads of different permiatations of the code last night but thanksfully you know what you're doing!

    Cheers!
     

Share This Page