DakotaChick
11-23-2007, 12:36 AM
Hey guys, I'm using a for each next loop to cycle through some form field requests, everything works fine for the first 3 fields that meet the requirements but the 4 field throws an EOF/BOF Error even though I know the requested information exists in the database and does not have duplicate entries under the same name. The code is below, and I'm also open to suggestions on how to combine some of the work thats going on in this file. I know its probably not the most efficent way of working...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #Include file = "admin/conn.inc" -->
<%
'Insert Quote Information
strSQL = "SELECT Quotes.* FROM Quotes;"
rs.Open strSQL, adoCon, 3, 3
Today = date
IP = Request.ServerVariables("REMOTE_HOST")
rs.AddNew
rs("IP") = IP
rs("QuoteDate") = Today
rs("Total") = Request.Form("Total")
rs.Update
rs.Close
'Retrieve Quote ID From Record Just Inserted
strSQL = "SELECT Quotes.ID FROM Quotes WHERE IP='" & IP & "' AND QuoteDate='" & Today & "';"
rs.Open strSQL, adoCon
QuoteID = rs("ID")
rs.Close
Dim rs2, strSQL2
Set rs2 = Server.CreateObject("ADODB.RecordSet")
'Retrieve Form Fields
For Each fld In Request.Form
'Filter out the unnecessary fields
If Instr(fld, "Price") = 0 AND Instr(fld, "Qty") = 0 Then
Short = Request.Form(fld)
'Retrieve Product ID and Price for Selected Product
strSQL = "SELECT ProdSvc.ID, ProdSvc.Price FROM ProdSvc WHERE Name='" & Short & "';"
rs.Open strSQL, adoCon
ProdID = rs("ID")
Price = rs("Price")
rs.Close
'Insert Quote Item Information
strSQL2 = "SELECT QuoteItems.* FROM QuoteItems;"
rs2.Open strSQL2, adoCon, 3, 3
rs2.AddNew
rs2("QuoteID") = QuoteID
rs2("ProdID") = ProdID
rs2("Price") = Price
rs2.Update
rs2.Close
End if
Next
'Retrieve Last Needed Fields
For Each fld In Request.Form
If Instr(fld, "Qty") Then
Qty = Request.Form(fld)
'Retrieve Proper Quote Item and Insert Qty
strSQL = "SELECT QuoteItems.* FROM QuoteItems WHERE ProdID='" & ProdID & "';"
rs.Open strSQL, adoCon, 3, 3
rs("Qty") = Qty
rs.Update
rs.Close
End if
Next
'Destroy Objects
adoCon.Close
Set rs = Nothing
Set rs2 = Nothing
set adoCon = Nothing
Response.Redirect "customer.asp"
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #Include file = "admin/conn.inc" -->
<%
'Insert Quote Information
strSQL = "SELECT Quotes.* FROM Quotes;"
rs.Open strSQL, adoCon, 3, 3
Today = date
IP = Request.ServerVariables("REMOTE_HOST")
rs.AddNew
rs("IP") = IP
rs("QuoteDate") = Today
rs("Total") = Request.Form("Total")
rs.Update
rs.Close
'Retrieve Quote ID From Record Just Inserted
strSQL = "SELECT Quotes.ID FROM Quotes WHERE IP='" & IP & "' AND QuoteDate='" & Today & "';"
rs.Open strSQL, adoCon
QuoteID = rs("ID")
rs.Close
Dim rs2, strSQL2
Set rs2 = Server.CreateObject("ADODB.RecordSet")
'Retrieve Form Fields
For Each fld In Request.Form
'Filter out the unnecessary fields
If Instr(fld, "Price") = 0 AND Instr(fld, "Qty") = 0 Then
Short = Request.Form(fld)
'Retrieve Product ID and Price for Selected Product
strSQL = "SELECT ProdSvc.ID, ProdSvc.Price FROM ProdSvc WHERE Name='" & Short & "';"
rs.Open strSQL, adoCon
ProdID = rs("ID")
Price = rs("Price")
rs.Close
'Insert Quote Item Information
strSQL2 = "SELECT QuoteItems.* FROM QuoteItems;"
rs2.Open strSQL2, adoCon, 3, 3
rs2.AddNew
rs2("QuoteID") = QuoteID
rs2("ProdID") = ProdID
rs2("Price") = Price
rs2.Update
rs2.Close
End if
Next
'Retrieve Last Needed Fields
For Each fld In Request.Form
If Instr(fld, "Qty") Then
Qty = Request.Form(fld)
'Retrieve Proper Quote Item and Insert Qty
strSQL = "SELECT QuoteItems.* FROM QuoteItems WHERE ProdID='" & ProdID & "';"
rs.Open strSQL, adoCon, 3, 3
rs("Qty") = Qty
rs.Update
rs.Close
End if
Next
'Destroy Objects
adoCon.Close
Set rs = Nothing
Set rs2 = Nothing
set adoCon = Nothing
Response.Redirect "customer.asp"
%>