Click to See Complete Forum and Search --> : Querystring


aseelbathery
02-11-2007, 08:40 AM
i need to retrieve the anchor links from the database according to the querystrings of the id taken from the database.when i execute this code i get the following error

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/tc/machinery.asp, line 28.

Here is my code.
---------------

<%
Dim Ors,id
Dim category_name
Set Ors = Server.CreateObject("Adodb.Recordset")
Ors.Open "SELECT tbl_subcategory.subcategoryName FROM tbl_subcategory,tbl_postproducts WHERE tbl_subcategory.subcategoryID=tbl_postproducts.subcategoryID",cnnDB
query_id = Ors.Fields("tbl_postproducts.subcategoryID") // Here is the error i'm getting
'Response.Write id
%>
<div class="sub_category_list">
<%do until Ors.EOF
for each x in Ors.Fields
%>
<% Response.Write("<a href="&x.value&"?id="&query_id&" onclick=goto())>" & x.value & "</a>"&"<br>")%>
<%

next
Ors.MoveNext%>
<%loop
Set Ors = Nothing
%>

Can anybody help me?

russell
02-11-2007, 11:26 AM
subcategoryName is the only field you've selected. but you are trying to access subcategoryID from the recordset.

need to select any fields that your code will reference.

aseelbathery
02-12-2007, 01:49 AM
Thanks for replying me. in the above code can you please tell me i need to pass value of querystring from the database. i need to take the subcategoryID which is a foriegn key in the table and ccording to this i've to display . i'll give you the database design

Table Products
-------------
ProductID PKey and Auto Number
Product Image
Product Title
ProductDescription
SubcategoryID FKey from the subcategory Table


<%
Dim Ors,id
Dim category_name
Set Ors = Server.CreateObject("Adodb.Recordset")
Ors.Open "SELECT tbl_subcategory.subcategoryName,tbl_postproducts.FileID FROM tbl_subcategory,tbl_postproducts WHERE tbl_postproducts.subcategoryID=tbl_subcategory.subcategoryID",cnnDB
query_id = Ors.Fields("FileID")
'Response.Write id
%>
<div class="sub_category_list">
<%do until Ors.EOF
for each x in Ors.Fields
%>
<% Response.Write("<a href="&x.value&"?id="&query_id&" onclick=goto())>" & x.value & "</a>"&"<br>")%>
<%
next
Ors.MoveNext%>
<%loop
Set Ors = Nothing
%>

russell
02-14-2007, 10:40 AM
which field is the url u want to appear in the link? let's see the subcategory table too

aseelbathery
02-15-2007, 02:07 AM
Subcategory Field i need to add in the url part. i'm giving you the subcategory Table


SubcategoryID PKey
SubcategoryName
CategoryID FKey

russell
02-15-2007, 04:21 PM
try

Response.Write "<a href=""" & Ors("subcategoryName") & "?id=" & Ors("FileID") & """ onclick=""goto()"">" & Ors("subcategoryName") & "</a><br>" & vbCrLf

aseelbathery
02-17-2007, 04:48 AM
Thanks for your reply. in your last reply, can you please tell me how can i list propertyimage,propertyDescription,supplier name etc from the database?

i mean on clicking on the anchor link which we were discussing in the previous mail?

Thanks & Regards