...

View Full Version : insert multiple value in 1 table



rosehabib
04-09-2006, 11:34 AM
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..

miranda
04-09-2006, 04:36 PM
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

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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum