Click to See Complete Forum and Search --> : passing values in asp from page to page.


tasneem
05-09-2005, 05:57 PM
Hi
I have a msaccess db, with relational tables like
tblmastercategory, tblcategory, tblmastersku etc. Both tblmastercategory and tblcategory are related to tblmastersku, but not to each other.
I have the asp page for tblmastercategory with links to open tblcategory for that mastercategory. This is something like this:(line breaks for readability)

tblmastersku has

mastercategoryid
categoryid
otherfields


tblmastercategory has

mastercategoryid
mastercategoryname


tblcategory has

categoryid
categoryname


I have put the link in tblmastercategory like this:

<%
dim strsql
DIM qrycats 'to pass value to categories.asp page.
'then more asp code to open the recordset.
' then below is the link
<a href="categories.asp?qrycats=<%= rsmaincats("MasterCategoryID") %>">
<% response.Write (rsmaincats.Fields("MasterCategoryName").Value) %></a>


This is working till now, it passes the query to qrycats in the next page of categories.asp where I have this code:

<%
DIM qrycats 'value passed from mastercategories.asp
dim strsql 'sql query

strsql = "SELECT DISTINCTROW tblCategoryNames.CategoryID,
tblCategoryNames.CategoryName,
tblMasterCategoryNames.MasterCategoryID,
tblMasterSKU.MasterCategoryID FROM tblMasterCategoryNames
INNER JOIN (tblCategoryNames INNER JOIN tblMasterSKU ON
tblCategoryNames.CategoryID = tblMasterSKU.CategoryID) ON
tblMasterCategoryNames.MasterCategoryID =
tblMasterSKU.MasterCategoryID
WHERE tblMasterSKU.MasterCategoryID= '"& qrycats &"' ;"


This gives me this error:


ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/miscprojects/midtownofficesupplies/catsprods/categories.asp,
line number



Can someone help me here?

thanks

buntine
05-09-2005, 07:52 PM
This error means that no records are being returned from the query. The page that executes the query seems to be missing a line. You are not defining what qrycats equals.

qrycats = Request.QueryString("qrycats")

Regards.

tasneem
05-13-2005, 01:54 PM
Hi
I have been able to code the pages until subcategory, but I am stuck with the products page. Here is the live site (http://site272.webhost4life.com/dzigner/catesprods/mastercategories.asp).
This is the error in the products.asp page:

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/dzigner/catesprods/products.asp, line 0


Here is the code for that page:
[code]
<% ' ADO constants used in this page
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
%>
<!--#include file="dbconn.asp" -->
<%
Dim midtowncnn ' db connection
Dim rsprods ' recordset
dim strsql 'sql query
Dim qryprods ' qry passed from subcategories.asp
dim qryprodinfo 'qry passed to productinfo.asp



' DB connection and recordset query.
Set midtowncnn = Server.CreateObject("ADODB.Connection")
Set rsprods = Server.CreateObject("ADODB.Recordset")
midtowncnn.open dsnmidtown

strsql = "SELECT DISTINCT tblMasterProductGroups.ShortDescription, tblSKUProductGroupLinks.ProductGroupID, tblMasterSKU.SKU, tblMasterSKU.SubCategoryID, tblSubCategoryNames.SubCategoryName, tblMasterSKU.Description FROM tblMasterProductGroups INNER JOIN ((tblSubCategoryNames INNER JOIN tblMasterSKU ON tblSubCategoryNames.SubCategoryID = tblMasterSKU.SubCategoryID) INNER JOIN tblSKUProductGroupLinks ON tblMasterSKU.SKU = tblSKUProductGroupLinks.SKU) ON tblMasterProductGroups.ProductGroupID = tblSKUProductGroupLinks.ProductGroupID WHERE tblMasterSKU.SubCategoryID = '"& qryprods &"' ORDER by ShortDescription;"
rsprods.open strsql,midtowncnn, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect

%>

the html output

<%
DO UNTIL rsprods.eof%>
<tr>
<td width="8%" colspan="5"><div align="center">*</div></td>
<td width="92%"><%' response.Write rsprods("ShortDescription") %></td>
<!--tblMasterProductGroups.ShortDescription, tblSKUProductGroupLinks.ProductGroupID, tblMasterSKU.SKU, tblMasterSKU.SubCategoryID, tblSubCategoryNames.SubCategoryName, tblMasterSKU.Description-->
</tr>
<tr>
<td>MasterSKU</td>
<td>SubCategoryID</td>
<td>SubCategoryName</td>
<td>ProductGroupID</td>
<td colspan="2">ShortDescription</td>
</tr>
<tr>
<td><% response.Write rsprods("SKU") %></td>
<td><% response.Write rsprods("SubCategoryID") %></td>
<td><% response.Write rsprods("SubCategoryName") %></td>
<td><% response.Write rsprods("Description") %></td>
<td colspan="2"><% response.Write rsprods("ShortDescription") %></td>
</tr>
<%
rsprods.MoveNext
LOOP
rsprods.Close
Set rsprods = Nothing

%>



Any ideas why this query works in Access db, but not on the ASP page?
thanks

buntine
05-13-2005, 09:49 PM
Same as before. It looks to me like qryprods is empty.

Try this before the query and comment out anything thay may cause errors (execute statements, etc):

Response.Write("Qryprods = " & qryprods)

What does it print out?

To pass data form page to page, you have two options. One; use the QueryString, which is the name/value pairs that are appended to the URL. (page.asp?name1=value1&name2=value2). Two; you can use the Form collection, which is passed behind the scenes and can only be used with an HTML form (by setting action="post").

qryprods = Request.QueryString("qryprods")
' OR
qryprods = Request.Form("qryprods")

Regards.

tasneem
05-16-2005, 01:09 PM
Hi
Thanks for saving my life (or atleast my sanity)
Now, just for my knowledge:
I have passed the same code page by page, without the querystring or form code like this:
from mastercategories.asp to categories.asp

<a href="products.asp?qryprods=<%= rscats("CategoryID") %>">
<% response.Write rscats("CategoryName") %>

and so on also for subcategories.asp page. The querystring is passed OK, without calling it out like qrycats=request.querystring. So why didnt it work in the products.asp page? Why do I have to use the request.querystring code in this page only?
You can view the site here (http://site272.webhost4life.com/dzigner/catesprods/mastercategories.asp).
Thanks again for helping me thru this.

tasneem
05-16-2005, 01:24 PM
HI
OOOOOOPS,
I am sorry, I had a similar code on every page :)
thanks again.

buntine
05-16-2005, 09:38 PM
Thats alright. Glad to help out. ;)