Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL , ASP ???

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
I'm not too sure which forum to ask, so i'll do this and asp. Hello all. I have a database with 4 tables,
---------------------------------
Categories:
CategoriesID (primary key)
Categories (text)
----------------------------------
Products:
ProductID (primary key)
Manufacturer (text)
PartNumber (text)
Description (memo)
CategoriesID (foreign key)
----------------------------------
Jobs:
JobCode (primary key
JobStatus (text)
Etc. Etc....
----------------------------------
Orders:
OrdersID (primary key)
ProductID (foreign key)
JobCode (foreign key)
Quantity (text)
----------------------------------
I have an asp page with a table containing 4 cells. The first 3 cells are populated with data pulled form the Products table in the database with this sql statement.

SELECT * FROM Products WHERE CategoriesID=1

That will pull and display all of the data from a category in the products table. that part is working fine. the first 3 cells display the information, Manufacturer, PartNumber, Description, with no problem.
In the 4th cell I placed a form tag, and a text box to update the quantity field in the orders table with whatever quantity is entered into the textbox. Now here's the part i'm getting lost on. how do i update the quantity field in the orders table, and have it related to the JobCode? Here's the logic (or lack thereof) of the system.
i have a page that list's all the jobs. From there you click on a JobCode (hyperlink = products.asp?JobCode=<%=rsPSS(&quot;JobCode&quot;)%>) and it'll take you to another page listing all the product categories (widgets, lightbulbs, etc. etc....) From there you click a category (widgets for example) next you go to a page that lists all the widgets, from here you can enter the quantity you want. Now how can i make it so the orders table is updated with the quantity of widgets you entered and have the JobCode updated as well with the JobCode you selected at the beginning? sorry guys i'm in this one so deep i can't see the answer clearly.
 
A couple of ways to do this. You can build each subsequent page with the job code plugged into the querystring just as you did on the first page. If your pages have forms as well as links you can create a hidden field in the form that has the value of the job code found in the querystring. Or on the second page put the job code into a session variable. It will be available in any subsequent page.

So in products.asp you would use one of these -
Code:
<%
var jobCode = Request.Querystring(&quot;JobCode&quot;);
%>
<!-- Put the job code in every link with the category codes. -->
<a href=&quot;widgets.asp?JobCode=<%= jobCode %>&Category=<%= rsPSS(&quot;Category&quot;) %>&quot;>

<!-- Put the job code in a hidden field in a form. -->
<input type=&quot;hidden&quot; value=&quot;<%= jobCode %>&quot;>

<%
//Put the job code in a session variable.
Session(&quot;JobCode&quot;) = jobCode;
%>
 
Thanks for the reply.. :) i think i may have at least figured out how to pass the jobcode. I needed to create a form on the first page, i made a hidden field, and on the second page put the value from the hidden field into a session variable. i needed to do this cause when i did query strings from any of the other pages after page 1 it wasn't working. So now with all that done. How do i get the jobcode to write to the database along with the quantity. foe example this quantity is for this jobcode. thanks again.
 
Ok, cool it's updating the quantity and jobcode in the orders table.. one last thing. How do i make it so the correct productID is inserted as well? thanks a million for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top