Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem looping

Status
Not open for further replies.

bikebanditcom

Programmer
Jun 11, 2003
117
US
I have the following code trying to look thru an array and then save each item from the array as one record, but instead its loading for example all partNumber's into one record a piece, then it does the same with each. any ideas on how to get it all to insert as one record? thanks ahead of time.

set adminDB = Server.CreateObject("ADODB.Connection")
adminDB.open "admin"

for each partNumber in request.form("partNumber")
partInfo = "insert into tblPartInfo (partNumber) values ('"&partNumber&"')"
next
adminDB.Execute(partInfo)
for each qty in request.form("qty")
qtyInfo = "insert into tblPartInfo (qty) values ('"&qty&"')"
next
adminDB.Execute(qtyInfo)

for each dealer in request.form("dealer")
dealerInfo = "insert into tblPartInfo (dealer) values ('"&dealer&"')"
next
adminDB.Execute(dealerInfo)

for each mercValue in request.form("mercValue")
mercValueInfo = "insert into tblPartInfo (mercValue) values ('"&mercValue&"')"
next
adminDB.Execute(reasonInfo)
for each reason in request.form("reason")
reasonInfo = "insert into tblPartInfo (reason) values ('"&reason&"')"
next
adminDB.Execute(shippedInfo)
for each shipped in request.form("shipped")
shippedInfo = "insert into tblPartInfo (shipped) values ('"&shipped&"')"
next
adminDB.Execute(UnreturnableToSuppInfo)
for each UnreturnableToSupp in request.form("UnreturnableToSupp")
UnreturnableToSuppInfo = "insert into tblPartInfo (UnreturnableToSupp) values ('"&UnreturnableToSupp&"')"
next
adminDB.Execute(CrdtToBeIssdInfo)
for each CrdtToBeIssd in request.form("CrdtToBeIssd")
CrdtToBeIssdInfo = "insert into tblPartInfo (CrdtToBeIssd) values ('"&CrdtToBeIssd&"')"
next
adminDB.Execute(Rcvd15DayInfo)
for each Rcvd15Day in request.form("Rcvd15Day")
Rcvd15DayInfo = "insert into tblPartInfo (Rcvd15Day) values ('"&Rcvd15Day&"')"
next
adminDB.Execute(custRestockingFeeInfo)
for each custRestockingFee in request.form("custRestockingFee")
custRestockingFeeInfo = "insert into tblPartInfo (custRestockingFee) values ('"&custRestockingFee&"')"
next
 
from the way I read your explanation I think your strucuter is suppose to be
for each partNumber in request.form("partNumber")
partInfo = partInfo & request.form("partNumber")
next

adminDB.Execute("insert into tblPartInfo (partNumber) values ('"&partNumber&"')")

when you loop through the form collection you don't do it like that though. at least I've never tried and not seen it so I could be wrong
it should be
for each item in request.form
If item = ""partNumber" Then
partInfo = partInfo & request.form("partNumber")
End If
next

I guess I'm still a biot confused on what your doing though

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
that won't work at all for me, i tried but to no avail, what i am trying to do is insert a dynamic section into the database, the section is a part info section that needs to all go in at once, every value the way i've written it, inserts a new line in the database. I'm not able to get it all to go in as one record. the way i've written the code, it inserts each value from each field into its own record line. it should all go together. any ideas? i'll post the page here.

<%@LANGUAGE=&quot;VBSCRIPT&quot; %>
<!--#include file=&quot;Connections/admin.asp&quot; -->
<% On Error Resume Next %>
<html>
<head>
<title>Insert Returns Into</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/return_style.css&quot;>
</head>
<%
empID = Request.Form(&quot;empID&quot;)
orderID = Request.Form(&quot;orderID&quot;)
bAmount = Request.Form(&quot;bAmount&quot;)
bDate = Request.Form(&quot;bDate&quot;)
california = Request.Form(&quot;california&quot;)
complete = Request.Form(&quot;complete&quot;)
custName = Request.Form(&quot;custName&quot;)
email = Request.Form(&quot;email&quot;)
partNumber = Request.Form(&quot;partNumber&quot;)
qty = Request.Form(&quot;qty&quot;)
dealer = Request.Form(&quot;dealer&quot;)
mercValue = CDbl(Request.Form(&quot;mercValue&quot;))
reason = Request.Form(&quot;reason&quot;)
UnreturnableToSupp = Request.Form(&quot;UnreturnableToSupp&quot;)
CrdtToBeIssd = Request.Form(&quot;CrdtToBeIssd&quot;)
custRestockingFee = Request.Form(&quot;custRestockingFee&quot;)
Rcvd15Day = Request.Form(&quot;Rcvd15Day&quot;)
RANempID = Request.Form(&quot;RANempID&quot;)
Rfault = Request.Form(&quot;Rfault&quot;)
Rshipping = Request.Form(&quot;Rshipping&quot;)
addOrigShipping = CDbl(Request.Form(&quot;addOrigShipping&quot;))
addRtrnShipping = CDbl(Request.Form(&quot;addRtrnShipping&quot;))
restockCalc = CDbl(Request.Form(&quot;mercValue&quot;) * .2)
shipped = Request.Form(&quot;shipped&quot;)
caSalesTax = CDbl(Request.Form(&quot;mercValue&quot;) * .08)

'This statement determines whether or not the product will be able to be returned
'and warns the user
If Dateadd(&quot;d&quot;,20,bDate) < Now() Then
Response.Write(&quot;This is too old !&quot;)
End If

If complete = &quot;Yes&quot; Then
If california = &quot;Yes&quot; Then
If shipped = &quot;Yes&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition One - valid
restockingFee = mercValue * .2
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax - restockingFee
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Two - invalid
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax
transType = &quot;Enter Credit&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Three - valid
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Four - valid - could be an exchange
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
ElseIf shipped = &quot;No&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Five - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Six - valid
restockingFee = mercValue * -.2
transAmount = restockingFee
transType = &quot;Enter Charge&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Seven - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Eight - valid - could only be a cancel within 1 hr
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
End If
End If
If california = &quot;No&quot; Then
If shipped = &quot;Yes&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Nine - valid
restockingFee = mercValue * .2
transAmount = mercValue + addOrigShipping + addRtrnShipping - restockingFee
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Ten - invalid
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping
transType = &quot;Enter Credit&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Eleven - valid - must be a bb error
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Twelve - valid - must be an exchange
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
ElseIf shipped = &quot;No&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Thirteen - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Fourteen - valid
restockingFee = mercValue * -.2
transAmount = restocking
transType = &quot;Enter Charge&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Fifteen - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Sixteen- valid - could only be a cancel within 1 hr
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
End If
End If
ElseIf complete = &quot;No&quot; Then
If california = &quot;Yes&quot; Then
If shipped = &quot;Yes&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition One - valid
restockingFee = mercValue * .2
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Two - invalid
restockingFee = mercValue * .2
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax - restockingFee
transType = &quot;Enter Credit&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Three - valid
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping + caSalesTax
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Four - valid - must be an exchange only i think
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
ElseIf shipped = &quot;No&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Five - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Six - valid
restockingFee = mercValue * -.2
transAmount = restockingFee
transType = &quot;Enter Charge&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Seven - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Eight - valid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
End If
ElseIf california = &quot;No&quot; Then
If shipped = &quot;Yes&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Nine - valid
restockingFee = mercValue * .2
transAmount = mercValue + addOrigShipping + addRtrnShipping - restockingFee
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Ten - invalid
restockingFee = mercValue * -.2
transAmount = mercValue + addOrigShipping + addRtrnShipping + restockingFee
transType = &quot;Enter Credit&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Eleven - valid
restockingFee = 0
transAmount = mercValue + addOrigShipping + addRtrnShipping
transType = &quot;Enter Credit&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Twelve - valid - could only an exchange
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
ElseIf shipped = &quot;No&quot; Then
If custRestockingFee = &quot;Yes&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Thirteen - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Fourteen - valid - could only be a cancel outside 1 hr
restockingFee = mercValue * -.2
transAmount = restockingFee
transType = &quot;Enter Charge&quot;
End If
ElseIf custRestockingFee = &quot;No&quot; Then
If CrdtToBeIssd = &quot;Yes&quot; Then
'Condition Fifteen - invalid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
ElseIf CrdtToBeIssd = &quot;No&quot; Then
'Condition Sixteen - valid
restockingFee = 0
transAmount = 0
transType = &quot;No Transaction&quot;
End If
End If
End If
End If
End If
%>

<% set adminDB = Server.CreateObject(&quot;ADODB.Connection&quot;)
adminDB.open &quot;admin&quot;

for each partNumber in request.form(&quot;partNumber&quot;)
partInfo = partInfo & request.form(&quot;partNumber&quot;)
next

for each qty in request.form(&quot;qty&quot;)
partInfo = partInfo & request.form(&quot;qty&quot;)
next

for each dealer in request.form(&quot;dealer&quot;)
partInfo = partInfo & request.form(&quot;dealer&quot;)
next

for each mercValue in request.form(&quot;mercValue&quot;)
partInfo = partInfo & request.form(&quot;mercValue&quot;)
next

for each reason in request.form(&quot;reason&quot;)
partInfo = partInfo & request.form(&quot;reason&quot;)
next

for each shipped in request.form(&quot;shipped&quot;)
partInfo = partInfo & request.form(&quot;shipped&quot;)
next

for each UnreturnableToSupp in request.form(&quot;UnreturnableToSupp&quot;)
partInfo = partInfo & request.form(&quot;UnreturnableToSupp&quot;)
next

for each CrdtToBeIssd in request.form(&quot;CrdtToBeIssd&quot;)
partInfo = partInfo & request.form(&quot;rdtToBeIssd&quot;)
next

for each Rcvd15Day in request.form(&quot;Rcvd15Day&quot;)
partInfo = partInfo & request.form(&quot;Rcvd15Day&quot;)
next

for each custRestockingFee in request.form(&quot;custRestockingFee&quot;)
partInfo = partInfo & request.form(&quot;custRestockingFee&quot;)
next

adminDB.Execute(&quot;insert into tblPartInfo (partNumber) values ('&quot;&partNumber&&quot;')&quot;)

adminDB.close

set adminDB = Nothing
%>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top