473,396 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Define a recordset within a function

I've got 20 pages that all have an identical code block that opens a db and assigns recordset to variables. Only difference is the product_id used in the query. I want to move this code to an include, and just call it on each page.
If I put the function on the actual page it works, but once I put it in the include I'm getting the error: Variable is undefined: 'prod_query'
I've tried doing it as both a sub and a function, but get the same error.
the include that defines the prod_query function is called before I try to use it. Any clues what I'm doing wrong? I'm not trying to return a value from the function, just using it to define variables I use later on the page.

<%@ Language=VBScript %>
<% OPTION EXPLICIT %>
<!--#include file="shop$db.asp"-->
<!--#include file="INC_prod_query.asp"-->
<%
Dim product_id
product_id = 69
Dim dbc, rs
shopopendatabaseP dbc
prod_query(product_id) ' call function in INC_prod_query.asp
%>

Here is the include file:
dim query, prod_name, prod_description, prod_extendeddesc, prod_ingredients, prod_price, prod_image, prod_weight
function prod_query(id)
query = "select cname, cdescription, extendeddesc, ingredients, pother1, cprice, cimageurl from products where catalogid = " & product_id
set rs = dbc.execute(query)
If not rs.EOF Then
prod_name = rs("cname")
prod_description = rs("cdescription")
prod_extendeddesc = rs("extendeddesc")
prod_ingredients = rs("ingredients")
prod_price = rs("cprice")
prod_image = rs("cimageurl")
prod_weight = rs("pother1")
end if
set rs=nothing
exit sub
end function
Mar 6 '07 #1
1 1950
iam_clint
1,208 Expert 1GB
query = "select cname, cdescription, extendeddesc, ingredients, pother1, cprice, cimageurl from products where catalogid = " & product_id

should be
query = "select cname, cdescription, extendeddesc, ingredients, pother1, cprice, cimageurl from products where catalogid = " & id

since your passing the variable to it.
Mar 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be...
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
4
by: Gerry Abbott | last post by:
Hi all. I wish to call a recordset from a function. Ive tried the following approach, -------------------------------------------------------- Function PassRS() As Recordset Dim db As...
0
by: Kevin R | last post by:
Question: I have a situation where I would like to prepare a Recordset object within Visual Basic (6.0), and then use the MS Access COM API's to Show a report built off of the data in my...
7
by: Jean | last post by:
Hello, I have a form that performs a search, according to criteria that a user enters into the text boxes. When the user clicks on „Search", a SQL string (say strSQL) is built up with the...
8
by: LabGeek | last post by:
Do I have to recreate a recordset everytime I want to use it, or can I simply create a recordset on the form open event and access it for the life of the form? I guess my question is really what...
2
by: fpennisi | last post by:
Hi all I have started writing a web app in Visual Studio 2005 (using c#). I am new to both C# and Visual Studio 2005. I will start by telling you what I need and then how I would have done it...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
4
by: phill86 | last post by:
Hi, Bare with me this is going to take some explaining and any help is much appreciated I have a form that stores details of sessions which include start/end date start/end time these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.