[thelist] ASP Loop Question

darren darren at web-bitch.co.uk
Wed Mar 20 09:48:00 CST 2002


On 20 March 2002 at 15:31:18, Feingold Josh S <Josh.S.Feingold at irs.gov> wrote:

FJS> I want to insert the variable data into a database as a separate row.  I
FJS> would also like to automate this process.

ooop...just occurred to me that you might be able to concatenate your sql
inserts and then run them by the execute method of the connection object.

this sort of thing seems to work on sql server and access as far as i know.

so something like:

   dim arrVariable(10)  <--- this might need to be arrVariable(9)
   arrVariable(0) = "string1"
   arrVariable(1) = "string2"
   ...
   arrVariable(9) = "string10"

   for x = 0 to ubound(arrVariables, 1)
      strSQL = strSQL & "INSERT INTO database (column) VALUES (' " & arrVariable(x) & " ');"
   next

   objConn.Execute(strSQL, lngRecsAffected, adCmdText)

only one call to the db, and no recordset.

hth,

darren.




More information about the thelist mailing list