Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - insert multiple rows
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

insert multiple rows

 Post Reply Post Reply Page  12>
Author
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Topic: insert multiple rows
    Posted: 28 January 2008 at 1:00pm
Hi,
What's the simplest way to insert multiple rows of data from one form into a database?
 
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2008 at 1:36pm
Not sure what type of form you are talking about. Depending on the DB you can simply paste from e.g. Excel to SQL. If it's a CSV you can write a little insert statement like
Insert into table1 (col1,col2,col3)
Select col1,col2,col3 from csvprovider

Again, it really depends where your data is coming from.
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2008 at 3:13pm
It is coming from a webform, where user should add 5 rows per submit.
like in tell a friend form, the user enters up to 5 email addresses, each should be inserted in a new row in the table,
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2008 at 3:15pm
Originally posted by michael michael wrote:

If it's a CSV you can write a little insert statement like
Insert into table1 (col1,col2,col3)
Select col1,col2,col3 from csvprovider
is there any example for this? if I want to insert from a csv file on server?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 28 January 2008 at 5:53pm
If you use classic ASP you would have to parse the file and read it in. Or you can setup a DSN to that CSV file and do basic SQL queries with it.

To insert from a web form into 5 different rows, you would just Request.Form each field and concatenate to a sql string, of course making sure each field is populated.
Back to Top
Scott07 View Drop Down
Groupie
Groupie


Joined: 04 July 2002
Location: United Kingdom
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scott07 Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2008 at 3:15pm
If the database is mysql then you can run one insert that creates more than one record like

insert into table(col) values('bob'), ('jim'), ('ted');

(though double check the syntax as that might not be right)
Back to Top
alemcherry View Drop Down
Newbie
Newbie


Joined: 20 January 2008
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote alemcherry Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2008 at 8:09pm
insert into tablename (col1, col2) values (val11, val12) (val21, val22) (val31, val33)
Back to Top
ffffffrabbit View Drop Down
Newbie
Newbie


Joined: 11 February 2011
Location: USA
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote ffffffrabbit Quote  Post ReplyReply Direct Link To This Post Posted: 11 February 2011 at 4:01pm
Classic ASP how do I do this:

insert into tablename (col1, col2) values (val11, val12) (val21, val22) (val31, val33)

[CODE]
< ="utf-8"><FORM METHOD="POST" ACTION="data_in.asp" NAME="FORMNAME">
..... do while Not rs.eof
%>
<input type="hidden" value="<%=rs("value_a" Name="VALUEA">
<input type="text" name="TEXT_A">
< ="utf-8"><input type="text" name="TEXT_B">
< ="utf-8"><input type="text" name="TEXT_C">

<%
rs.MoveNext
loop
rs.Close
set rs = nothing
%>
</FORM>

< ="utf-8">[CODE]
< ="utf-8">
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.