Insert to multiple tables while looping for one SQ

Results 1 to 2 of 2

Thread: Insert to multiple tables while looping for one SQ

  1. #1
    Join Date
    Dec 1969

    Default Insert to multiple tables while looping for one SQ

    I&#039;m trying to insert a record into 2 different tables. This is not the problem. The problem comes when I&#039;m trying to do a Loop for one of the SQL statements.<BR><BR>The reason I want to have a loop is that I need it to insert the entries on a form into one table. I have a form that has fields for several products I want to add to a products table.<BR><BR>My code is as follows:<BR><BR>&#060;%@LANGUAGE="VBSCRIPT"%&#062; <BR>&#060;!--#include file="Connections/connJobSheet.asp" --&#062;<BR>&#060;%<BR>set conn = server.createobject("adodb.connection")<BR>conn.op en MM_connJobSheet_STRING<BR><BR>dim conn<BR>dim strsql<BR>dim strsql2<BR>dim prod<BR><BR>strsql = ""<BR>strsql2 = ""<BR><BR>conn.BeginTrans<BR><BR>strSQL = "INSERT INTO jobsheet(jobNo, jobDesc, orderNo) Values(&#039;" & request("jobNo") & "&#039;, &#039;" & request("jobDesc") & "&#039;, &#039;" & request("orderNo") & "&#039;)"<BR>conn.execute(strSQL)<BR><BR>for prod = 1 TO 10<BR>strSQL2 = "INSERT INTO prodUse(jobNo, products) Values(&#039;" & request("jobNo"&prod) & "&#039;, &#039;" & request("products"&prod) & "&#039;)"<BR>conn.execute(strSQL2)<BR>next<BR><BR> if Err.Number &#060;&#062; 0 Then<BR>conn.RollbackTrans<BR>else<BR>conn.CommitT rans<BR>end if<BR><BR>conn.close<BR>set conn = nothing<BR>%&#062;<BR><BR>I get an error while executing the second SQL, strSQL2. Can anyone tell me what I&#039;m doing wrong? Thanks.

  2. #2
    Join Date
    Dec 1969

    Default What error? <eop>


Posting Permissions

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