• HEXUS
  • HEXUS.tv
  • channel
  • gaming
  • lifestyle
  • trust
  • community
  • ESReality
  • HEXUS.community discussion forumsVisit Corsair.com

    Welcome to the HEXUS.community discussion forums forums.

    You are currently viewing our boards as a guest which gives you limited access to view most discussions and other features. By joining our free community you will have access to post topics, respond to polls and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

    Go Back   HEXUS.community discussion forums > HEXUS.help - buying advice & technical queries > Operating systems & applications > Software and web development

    Software and web development Databases, graphics, programming, scripting and web development.

    Reply
     
    LinkBack Thread Tools
    Old 28-12-2006, 10:57 PM   #1 (permalink)
    Member
     
    Join Date: Jul 2003
    Location: Whitley Bay, UK
    Posts: 193
    Thanks: 0
    Thanked 1 Time in 1 Post
    ASP querystring database query

    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!
    pritsey is offline   Reply With Quote
    Old 29-12-2006, 10:03 PM   #2 (permalink)
    Large Member
     
    Join Date: Apr 2004
    Posts: 3,185
    Thanks: 14
    Thanked 14 Times in 13 Posts
    So basically you want to know how to pass a variable between pages? Really this is the first thing you should have learned how to do before starting on database processing (and understood the difference between get and post).

    What you want is to pass the clicked letter to your search page, and from there execute your sql query, substituting the correct letter in your query string.

    (Please bear in mind there are different ways of acheiving this, this isn't meant to be thourough as there is a horde of information on the net).

    Inside your master page:

    Code:
    <a href="details.asp?letter=a">A</a>
    <a href="details.asp?letter=b">B</a>
    <a href="details.asp?letter=c">C</a>
    'etc etc....
    Inside your details page:

    Code:
    Dim sqlLetter
    
    sqlLetter = CStr(Request("letter"))
    
    'Now use your SQL code and replace the letter constant with the above sqlLetter variable
    All from memory, so if it don't work....

    To err is human. To really foul things up ... you need a computer.
    yamangman is offline   Reply With Quote
    Old 30-12-2006, 12:31 AM   #3 (permalink)
    Member
     
    Join Date: Jul 2003
    Location: Whitley Bay, UK
    Posts: 193
    Thanks: 0
    Thanked 1 Time in 1 Post
    Thanks yamangman,

    Code I ended up using was ("course" is variable passed from prev page):

    mySQL="SELECT Courses.Company, Courses.[Address 1] FROM Courses WHERE Company LIKE '" & Request.QueryString("course") & "%'"
    pritsey is offline   Reply With Quote
    Reply

    Breadcrumb
    Go Back   HEXUS.community discussion forums > HEXUS.help - buying advice & technical queries > Operating systems & applications > Software and web development


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Trackbacks are On
    Pingbacks are On
    Refbacks are On
    Forum Jump

    Similar Threads
    Thread Thread Starter Forum Replies Last Post
    RMA Query billythewiz SCAN.care@HEXUS 7 07-11-2006 04:44 PM
    Urgent: ASP WriteLine method - Writing ASP? Stoo Software and web development 4 18-03-2005 04:03 PM
    Using a switch statement and MySQL database Kezzer Software and web development 2 15-10-2004 12:37 PM
    Interactive ASP database stuff joshwa Software and web development 8 31-03-2004 01:36 PM
    Database Query Languages Zathras Software and web development 8 19-11-2003 07:30 PM



    All times are GMT. The time now is 11:54 PM.

    Any representations/statements made on the HEXUS.community discussion forums are the representations/statements of the author i.e. the person/organisation making them. If any such representations/statements are disputed they are a matter between the parties concerned. HEXUS Limited accepts no responsibility for any misrepresentations, inaccurate or false statements made by any person/organisation other than HEXUS Limited employees.
    Powered by vBulletin® Version 3.7.4
    Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
    Content Relevant URLs by vBSEO 3.2.0
    © Copyright 2008 HEXUS® Limited. All rights reserved. Unauthorised reproduction strictly prohibited.