Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2004, 03:41 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing a varialbe

I am trying to make a list of names load by the first letter in that name based on the letter clicked.
So far I can load the Data like this
sSQL = "SELECT BandName, Genre, City, State, URL, Factoid, ID FROM Bands Where BandName Like 'A%'"
sSQL = sSQL & " ORDER BY BandName ASC "

This lists all Names starting with A

I want to Make it that the A would be passed in a variable.
Like the link would be something like this.
<a href=http://mydomain.com/alph.asp?vLET=A>A</a>
the variable letter would then be A
vLET=A

This is where I can't figure it out. The way of telling the page to do it.
sSQL = "SELECT BandName, Genre, City, State, URL, Factoid, ID FROM Bands Where BandName Like '&vLET%'"
sSQL = sSQL & " ORDER BY BandName ASC "

I need help with this.
By The Way this is and ASP page on Brinkster.

Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
__________________
Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old January 13th, 2004, 04:04 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

sSQL = "SELECT BandName, Genre, City, State, URL, Factoid, ID"
sSQL = sSQL & " FROM Bands Where BandName Like '" & vLET & "%'"
sSQL = sSQL & " ORDER BY BandName ASC "
 
Old January 13th, 2004, 04:08 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use a case statement

Case A
vlet=A
Case B
vlet=B
and so on
Then pass the value of vlet to the query string

John

 
Old January 14th, 2004, 02:16 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello For of all I don't understand this.
Quote:
quote:Originally posted by jrwlkn
 Use a case statement

Case A
vlet=A
Case B
vlet=B
and so on
Then pass the value of vlet to the query string

John

Second I tried this
sSQL = "SELECT BandName, Genre, City, State, URL, Factoid, ID"
sSQL = sSQL & " FROM Bands Where BandName Like '" & vLET & "%'"
sSQL = sSQL & " ORDER BY BandName ASC "

And it displayed all records.
It works fine on my test site but not on the live site it's on Brinkster.


Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old January 14th, 2004, 03:17 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try LIKE ' & vLet & "*"' as the search criteria

As for the letters to search on try using an option list instead of letters to click on. Set the value of the option list to vLet and pass it to the querystring.

The code to create the option list would be something like this

<SELECT Name="vLet">
<%
Dim intLetter, strChar
For intLetter 1-26
strChar=Chr(intLetter+64)
Response.Write "<OPTION VALUE= " & strChar & ">" & strChar & "</OPTION>
Next
%>
</SELECT>

This will allow a sort of dynamic string to pass to the URL ref



 
Old January 16th, 2004, 12:10 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

So what's it do on the live site?

 
Old January 16th, 2004, 01:00 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Not having more of the code posted, I kind of assumed that you were retrieving the value from the querystring for the letter you want to search on. You can't just implicitly use a variable name that matches a querystring argument name, you have to get it from the querystring collection:

vLET = Request.QueryString("vLET")

sSQL = "SELECT BandName, Genre, City, State, URL, Factoid, ID"
sSQL = sSQL & " FROM Bands Where BandName Like '" & vLET & "%'"
sSQL = sSQL & " ORDER BY BandName ASC "

The reason it returns everything is because if vLET isn't set to anything the query will search on "%" which will match everything.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with passing args Siblja Java Basics 1 February 6th, 2007 10:24 AM
passing infos yami56 Access 11 February 10th, 2005 03:12 PM
Passing value without using sessions lic023 Classic ASP Basics 1 July 20th, 2004 09:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.