Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    insert multiple value in 1 table

    hello..
    I have 1 problem. I want to insert multiple value into 1 table.
    my table name: store
    fields: item_code, item_name, uom.

    In 1 form, I want to insert multiple item in the table (store)..
    anyone can help me..

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    are you saying that you want to insert more than 1 record at a time? or just a simple insert of the values into 1 record from your form like I show below. The below code assumes a connection object named oConn

    if uom field is either Access data type text or memo
    Code:
    sSQL = "INSERT INTO store(item_code, item_name, uom) VALUES('" & Request.Form("item_code") & "','" & Request.Form("item_name") & "','" & Request.Form("uom") & "')" 
    oConn.Execute(sSQL)
    if uom fields is an Access data type number
    Code:
    sSQL = "INSERT INTO store(item_code, item_name, uom) VALUES('" & Request.Form("item_code") & "','" & Request.Form("item_name") & "'," & Request.Form("uom") & ")" 
    oConn.Execute(sSQL)

    if the uom field is automatically generated by the database Access Data type
    Autonumber
    Code:
    sSQL = "INSERT INTO store(item_code, item_name) VALUES('" & Request.Form("item_code") & "','" & Request.Form("item_name") & "')" 
    oConn.Execute(sSQL)
    If you want to insert more than 1 record at a time then you would just loop through the SQL statement


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •