PDA

View Full Version : Records only load once!


dmccarrick
12-06-2005, 01:21 PM
Hi,

Using some basic code to load some records from my database but the records i need only load for the first product in my database. It;'s driving me crazy! Heres the code:

_________________________________________________________________________________________
application("constring") = "Driver={MySQL ODBC 3.51 Driver}; Server=********; Database=******; UID=******; PWD=******; Option=3"
a = Request.QueryString("a")
Set oConn = Server.CreateObject("ADODB.connection")
oConn.connectionstring = application("constring")
oConn.open
Set oRS = oConn.execute("SELECT * FROM tblproduct WHERE (range_id)=" & a)
Set oRS2 = oConn.execute("SELECT tblproduct.product_id, tblproduct.range_id, tbldescriptions.description_id, tbldescriptions.description FROM tblproduct INNER JOIN tbldescriptions ON tblproduct.product_id = tbldescriptions.product_id WHERE (((tblproduct.range_id)=" & a & "))")
%>
<table width=526 align="right">
<%
Do While Not oRS.EOF
if oRS.fields("shop_item").Value >1 then
%>
<tr>
<td width=263>
<div class="table4">
<table>
<tr>
<td>
<a href="hot.asp?search=<%= oRS.Fields("product_id")%>"><img src="images/<%= oRS.Fields("image_file")%>" align="left" border="0"></a>
</td>
<td>
<div class="color20">
<h5><a href="hot.asp?<%= oRS.Fields("product_id")%>"><%= oRS.Fields("product_name")%></a></h5>
<div class="smallads">
<%
*******************problem area****************************************
Do While Not oRS2.EOF
IF oRS.fields("product_id") = oRS2.fields("product_id") Then
Response.write "*" & oRS2.fields ("description").Value & "<br />"
End If
oRS2.MoveNext
Loop
%>
*************************************************************************
</div>
<span class="color19">Price: £<%= FormatNumber(oRS.fields("standard_price"), 2)%></span>
</td>
</tr>
</table>
</div>
</td>
</tr>
<%
else
end if
oRS.movenext
Loop
oRS.Close
Set oRS = Nothing
______________________________________________________________________

The link to the page this is on is www.tradingstyle.co.uk/eshop/test2.asp?a=2.

As you can see, the descriptions for each product only load for the first product!

Please Help.

Thanks
Daniel

Bullschmidt
12-06-2005, 02:30 PM
Set oRS = oConn.execute("SELECT * FROM tblproduct WHERE (range_id)=" & a)
Set oRS2 = oConn.execute("SELECT tblproduct.product_id, tblproduct.range_id, tbldescriptions.description_id, tbldescriptions.description FROM tblproduct INNER JOIN tbldescriptions ON tblproduct.product_id = tbldescriptions.product_id WHERE (((tblproduct.range_id)=" & a & "))")


I'd seriously consider combining these two recordsets into one recordset.