Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 May 8th, 2007, 09:53 AM
Authorized User
 
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts
Default Database/Drop Down list help

I have a database that has several 'Courses' with 'Descriptions'. The classes are to be grouped by 'Category', using a 'CatalogID' as distinct separators. I have the coding to query the database and pull the 'Category' and place it in a drop down menu. But, the 'Courses' and 'Descriptions' are not being pulled onto the page, so somewhere I don't have my query right. I think I've stared at it too long and just can't see where I have the coding wrong. Hopefully someone can look at it and point out my error.

The <form> tag:


<form method="POST" action="select.asp?post=yes" querystring="y">

The drop down list:

<select name="Category" LANGUAGE="javascript" onchange="this.form.submit()">

<% Set rs = Server.CreateObject("adodb.recordset")
cmd = "SELECT distinct CatalogID, Category from Catalog"
rs.open cmd, conn

while not rs.eof
%>

<option value="<% = rs("CatalogID") %>"><%=rs("Category")%></option>

<% rs.movenext
wend
rs.close
%>
</select><noscript><INPUT type="submit" value="Go" name=submit></noscript>


The listing of the 'Courses' with 'Descriptions' on the page:

<% if request.querystring("POST") = "y" Then
Set rs = Server.CreateObject("adodb.recordset")
cmd = "SELECT * FROM Catalog WHERE (Category LIKE '" & request("CatalogID") & "') order by Title"

rs.open cmd, conn

While not rs.eof %>


And the 'Course' listing:

<p><b><% = rs("Title")%></b></p>

<p><%=Rs("Description")%></p>


And, finally, the closing of the loop:

<% rs.movenext
Wend
rs.close
end if
Set rs = nothing
%>


Any help would be appreciated.
 
Old May 8th, 2007, 11:16 AM
Authorized User
 
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Update:

I narrowed the problem down by changing the line:


cmd = "SELECT * FROM Catalog WHERE (Category LIKE '" & request("CatalogID") & "') order by Title"

To:

cmd = "SELECT * FROM Catalog order by Title"

And get the full list of 'Titles' and 'Descriptions', though not in their respective 'Categories'. (of course)

So, my problem appeared to lie in:


WHERE (Category LIKE '" & request("CatalogID") & "')

So I had to ask myself, "Is my logic right in my WHERE statment?" And my answer was "Of course not." I had my WHERE statement backwards. It should read:

WHERE (CatalogID LIKE '" & request("Category") & "')

Works like a charm.



 
Old May 8th, 2007, 02:22 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

OK. It works. I just don't know why you are using LIKE.... Wouldn't the CategoryID actually equal (=) the CategoryID you're trying to pull?

 
Old May 10th, 2007, 11:13 AM
Authorized User
 
Join Date: Apr 2006
Posts: 31
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I'm using LIKE because I'm a beginner and that was the example I had to go by. But I do know I can't use = because the values in CatalogID are different from Category, that they are not =.

I did not know that my beginner status would offend so much, and would warrant such an out-of-patience answer. I'm sorry and will stay out of these forums until I have a better handle on the programming.

 
Old July 30th, 2007, 03:48 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think jackiew has to chill out. I didn't think the reply from rstelma was offensive in the least and had a valid point. It was just a question after all.






Similar Threads
Thread Thread Starter Forum Replies Last Post
multi column database source for drop down list mii2029 ASP.NET 3.5 Basics 3 August 4th, 2008 05:05 PM
Get data from database based on drop down list sel stapes ASP.NET 2.0 Basics 0 May 22nd, 2008 11:15 AM
Create a drop down list using database values erinrox JSP Basics 1 September 4th, 2007 06:59 AM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM





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