ASP and using linked tables

Discussion in 'ASP General' started by Dave, Feb 2, 2005.

  1. Dave

    Dave Guest

    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
     
    Dave, Feb 2, 2005
    #1
    1. Advertising

  2. Dave

    Adrienne Guest

    Gazing into my crystal ball I observed "Dave" <>
    writing in news:ktbMd.2673$:

    > 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.
    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Feb 3, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    514
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    504
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    549
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    705
    John Carson
    Oct 2, 2006
  5. pratap
    Replies:
    20
    Views:
    792
    Flash Gordon
    Mar 7, 2007
Loading...

Share This Page