![]() | ![]() |
|
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! |
|
|||||||
| Software and web development Databases, graphics, programming, scripting and web development. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#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! |
|
|
|
|
|
#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.... Code:
Dim sqlLetter
sqlLetter = CStr(Request("letter"))
'Now use your SQL code and replace the letter constant with the above sqlLetter variable
To err is human. To really foul things up ... you need a computer.
|
|
|
|
|
|
#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") & "%'" |
|
|
|
![]() |
| Breadcrumb | ||||||
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
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 |