faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Database Backed Sites

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

65 of 88 people (74%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I insert multiple rows into a database using asp?

Aug 22nd, 2001 02:47
Simon Burnett, unknown unknown, Michael Brinkley, Michiel van Otegem


It's not possible to insert more than one row at a time.

You can only insert one row at a time. Try using a loop.


Or, you could use UpdateBatch instead of Update. It batches the updates 
together and then performs them.



------------------------------------------

By the way - if you are inserting a lot or records try building up lots 
of INSERT commands in one SQL string then run that. One database call 
rather than an Execute command for each line.

example:

Use, 

FOR x = 1 TO 1000
  strSQL = strSQL & "INSERT INTO tblNumber (num) VALUES (" & x & ");"
NEXT
objConn.Execute strSQL

Rather than,

FOR x = 1 TO 1000
  strSQL="INSERT INTO tblNumber (num) VALUES (" & x & ");"
  objConn.execute strSQL
NEXT

It will save loads of time.



© 1999-2004 Synop Pty Ltd