Insert recordset into Database

Results 1 to 2 of 2

Thread: Insert recordset into Database

  1. #1
    besharah Guest

    Default Insert recordset into Database

    I&#039ve got an ADO recordset with 150 records on my ASP Page. I want to insert the data from this recordset into a SQL Server Database. I could loop through each row of the recordset and insert the data one row at a time. This, of course, would mean 150 separate trips to the database. So.....What is the least resource intensive way to get multiple records into the database? I&#039m taking any ideas, any suggestions...<BR><BR>Thanks in advance.

  2. #2
    Join Date
    Dec 1969

    Default RE: Insert recordset into Database

    there&#039s probably a better way to do this, but i haven&#039t had to do much of what you&#039re trying...<BR><BR>instead of:<BR><BR>Do While<BR>strSQL="SELECT Stuff FROM Access"<BR>rs.Open strSQL<BR>strSQL="INSERT INTO sqlserver(field) Values(&#039" & rs(0) & "&#039)"<BR>con.execute strSQL<BR>Loop<BR><BR>which, in effect means you&#039re making one trip to each database per loop, in your loop, build a single long slq statement with multiple INSERTs execute that statement outside of the loop...<BR><BR>now you&#039re making 11 trips to databases (10 to access, 1 to sql) instead of 20 (10 to each)...<BR><BR>if you find a better way, share...<BR>

Posting Permissions

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