ASP and using linked tables

D

Dave

Hi folks,

I'm fairly new to the ASP/SQL arena and need a hand wrapping my mind around
something. First allow me to paint you a picture:

I'm developing an ASP page (not .net) for inventory management.

At the moment I have 2 tables.

1) ProductTable has the following columns: ID, Part, Description, Price and
Manufacturer (INT value)

2) ManufacturerTable: ID (key to manufacturer above), ManuName

I have a form in which a user enters information on a new product and on
this form I have a drop down list which is populated via the ManuName table
which displays all available manufacturers from the
manufacturertable.manufacturer column.

What I want is that when a user hits submit, it saves the info to the
producttable and takes the corresponding integer from the
ManuName that the user selects and places it in the
ProductTable.Manufacturer value along with the rest of the info. I'm unsure
of how to capture the corresponding integer value based on the Manufacturer
Name (which is a text value) and send it to the ASP file doing the actual
insert. Can anyone lend a hand?

Thanks,
Dave
 
A

Adrienne

Hi folks,

I'm fairly new to the ASP/SQL arena and need a hand wrapping my mind
around something. First allow me to paint you a picture:

I'm developing an ASP page (not .net) for inventory management.

At the moment I have 2 tables.

1) ProductTable has the following columns: ID, Part, Description, Price
and Manufacturer (INT value)

2) ManufacturerTable: ID (key to manufacturer above), ManuName

I have a form in which a user enters information on a new product and
on this form I have a drop down list which is populated via the
ManuName table which displays all available manufacturers from the
manufacturertable.manufacturer column.

What I want is that when a user hits submit, it saves the info to the
producttable and takes the corresponding integer from the
ManuName that the user selects and places it in the
ProductTable.Manufacturer value along with the rest of the info. I'm
unsure of how to capture the corresponding integer value based on the
Manufacturer Name (which is a text value) and send it to the ASP file
doing the actual insert. Can anyone lend a hand?

You have the id of the manufacturer as you pull it out for the drop down
don't you?

<form method="post" action="post.asp">
<label for="manufacturer">
<select name="manufacturer" id="manufacturer">
<%
While Not rs.EOF
id = trim(rs("manufacturer"))
manuname = trim(rs("manuname"))%>
<option value="<%=id%>"><%=manuname%></option>
<% rs.MoveNext
wend
rs.Close
set rs = nothing
%>
</select>
</label>
<label for="part">
<input type="text" id="part" name="part" value="<%=part%>" /></label>
<label for="description">
<input type="text" id="description" name="description" value="<%
=description%>" /></label>
<label for="price">
<input type="text" id="price" name="price" value="<%=price%>" />
</label>
<input type="submit" value="Submit" />
</form>

Now in Post.asp

<% manufacturer = request.form("manufacturer")
part = request.form("part")
description = request.form("description")
price = request.form("price")

insert = "INSERT INTO producttable "
insert = insert & " (Part, Description, Price, Manufacturer)"
insert = insert & " VALUES ('" & part & "', '" & description & "', '" &
price & "', " & manufacturer & ")"

Have a look at http://www.intraproducts.com/beta/requiredform.asp for some
ways to deal with required information, and other code snippets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top