Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 October 9th, 2008, 11:43 AM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default using a querystring to retrieve data from database

I am very very new on asp,

I am working on this page:
http://www.chloecloset.com/products_new.asp

These products have a category in the database. My question is, how do I tell the webpage to retrieve only the products from the category that I want. How can I pass that information from a previous page so the products_new.asp page knows which products to put in the dynamic table?

In the old products.asp page this worked with this string in the url box:
http://www.chloecloset.com/products.asp?cat=98

the fields that my recordset have are:
pDescription, pID, pImage, pSection

I think pSection is equal to cat number

Please advice, I am attaching my code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
Dim rsProducts
Dim rsProducts_numRows

Set rsProducts = Server.CreateObject("ADODB.Recordset")
rsProducts.ActiveConnection = MM_chicvintage_STRING
rsProducts.Source = "SELECT pDescription, pID, pImage, pSection FROM products ORDER BY pSection ASC"
rsProducts.CursorType = 0
rsProducts.CursorLocation = 2
rsProducts.LockType = 1
rsProducts.Open()

rsProducts_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
rsProducts_numRows = rsProducts_numRows + Repeat1__numRows
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; ">
<title>products new</title>
</head>

<body>

<table border="1">
    <tr>
    <%
'***************************
' http://www.DwZone.it
' DwZone Horizontal Looper
' Version 1.1.2
' Before Selection Code
'***************************
dwzLooperCol = 5
dwzLooperRow = 2
dwzCol = 0
dwzRow = 0
do while not rsProducts.eof
    dwzCol = dwzCol + 1
%><td><table width="250" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><a href="http://www.chloecloset.com/proddetail.asp?prod=<%=(rsProducts.Fields.Item("pI D").Value)%>"><img src="<%=(rsProducts.Fields.Item("pImage").Value)%> " border="0"></a><br>
      <%=(rsProducts.Fields.Item("pDescription").Value)% ></td>
  </tr>
</table></td><%
'***************************
' http://www.DwZone.it
' DwZone Horizontal Looper
' Version 1.1.2
' After Selection Code
'***************************
    if dwzCol = dwzLooperCol then
        response.write("</t" & " r>" & vbcrlf & "<t" & "r>")
        dwzCol = 0
        dwzRow = dwzRow + 1
    end if
    if dwzRow >= dwzLooperRow and dwzLooperRow <> -1 then
        exit do
    end if
    rsProducts.MoveNext
loop
for dwz_i = (dwzCol+1) to dwzLooperCol
    response.write("<t" & "d>&nbsp;</t" & "d>")
next
%>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<%
rsProducts.Close()
Set rsProducts = Nothing
%>

&lt;a href="http://www.ildw.com"&gt;Houston Web Design&lt;/a&gt;
 
Old October 9th, 2008, 02:37 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You posted to the wrong forum. Your question is about classic ASP and you posted to an ASP.NET forum.

You have some really strange looking and, I think, unnecessary code in there, if you care.

I'd love to rewrite it and make it about half or one-third the size it is now.

But the short answer is *PROBABLY* that all you need right now is to change the line
    rsProducts.Source = "SELECT pDescription, pID, pImage, pSection FROM products ORDER BY pSection ASC"
to
    rsProducts.Source = "SELECT pDescription, pID, pImage, pSection FROM products " _
                      & " WHERE pSection = " & CLNG(Request("categoryNumber")) _
                      & " ORDER BY pID ASC"
(no point in doing ORDER BY pSection, since now *all* products shown will be in just on pSection)

*************

I will say that this line is just plain WRONG:
     response.write("</t" & " r>" & vbcrlf & "<t" & "r>")
it will result in output of
    </t r>
    <tr>
and the space between the "t" and "r" is bogus. In any case there's no reason to split the output like that. And the parens around the whole thing are, technically, an error. So just use
      response.write "</tr>" & vbcrlf & "<tr>"

Ehhh...all the "DwZone Horizontal Looper" code is idiotic.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to retrieve data from database saleha Crystal Reports 1 March 7th, 2009 12:00 AM
Passing data via querystring LanceRoss Beginning VB 6 3 July 25th, 2008 12:20 PM
Submit Form with QueryString Data Phil06 Javascript 4 June 15th, 2007 06:11 PM
querystring + database + redirect animeshb Classic ASP Basics 1 February 14th, 2007 03:08 PM
Retrieve data from database and populate on PDF kotaiah Java Basics 1 February 13th, 2007 06:00 AM





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