Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

ASP Looping issue


  • Please log in to reply
No replies to this topic

#1 KamakaZ

KamakaZ

  • Members
  • 739 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Victoria
  • Local time:09:51 AM

Posted 07 April 2010 - 09:41 PM

I originally had the result printing down in a 2 column table, but I want to print them in a 6 column table. I came up with this ASP, but can't get it to work. Any suggestions appreciated!

'3rd Connection and SQL
DIM objConn3
Set objConn3 = Server.CreateObject("ADODB.Connection")
objConn3.ConnectionString = "DSN=GunnSrvModODBC"
objConn3.Open

DIM quantity_add3, quantity_final3, amount_add3, amount_final3
quantity_final3 = 0
amount_final3 = 0

DIM mySQL3
mySQL3 = "SELECT SJobs.Stock_No, SJobs.Job_No, SJobs.Completed_DT, Jservprt.Part_Code, Jservprt.Quan, Jservprt.Cost, Jservprt.Amount,DSTOCK.Description FROM (SJobs INNER JOIN Jservprt ON SJobs.Job_No = Jservprt.Job_No) INNER JOIN DSTOCK ON Jservprt.Part_Code = DSTOCK.Code WHERE SJobs.Stock_No LIKE '" & stock_no & "%' AND (SJobs.Completed_DT >= {ts '" & start_date & " 00:00:00'}) AND (SJobs.Completed_DT <= {ts '" & end_date & " 00:00:00'}) AND Jservprt.Part_Code <> ''"

DIM RS3
Set RS3 = Server.CreateObject("ADODB.Recordset")
RS3.Open mySQL3, objConn3

IF RS3.EOF THEN
	'Do nothing
ELSE
	Response.Write "<table border='0' cellspacing = '5' cellpadding = '5' >" 'starting an output table 
	RS3.movefirst
	DO WHILE NOT RS3.EOF
		DIM i
		i = 0
			IF i = 0

				Response.write "<tr>"
				Response.write "<td>" &  RS3("Part_Code") & "</td>"
				Response.write "<td>" &  RS3("Description") & "</td>"
				amount_add3 = RS3("Cost")
				quantity_add3 = RS3("Quan")
				quantity_final3 = quantity_final3 + quantity_add3
				amount_final3 = amount_final3 + amount_add3 
				IF RS3.EOF THEN
					Response.Write "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>"
					
				END IF
				RS3.movenext
				Response.write "<td>" &  RS3("Part_Code") & "</td>"
				Response.write "<td>" &  RS3("Description") & "</td>"
				amount_add3 = RS3("Cost")
				quantity_add3 = RS3("Quan")
				quantity_final3 = quantity_final3 + quantity_add3
				amount_final3 = amount_final3 + amount_add3 
				IF RS3.EOF THEN
					Response.Write "<td>&nbsp;</td><td>&nbsp;</td></tr>"
					END IF
				END IF
				RS3.movenext
				Response.write "<td>" &  RS3("Part_Code") & "</td>"
				Response.write "<td>" &  RS3("Description") & "</td>"
				amount_add3 = RS3("Cost")
				quantity_add3 = RS3("Quan")
				quantity_final3 = quantity_final3 + quantity_add3
				amount_final3 = amount_final3 + amount_add3 
				IF RS3.EOF THEN
					Response.Write "</tr>"
					END IF
				END IF
				RS3.movenext
				Response.write "</tr>"
				i = 1
			END IF
	Loop
Response.Write "</table>"
Response.Write "<br />"
Response.Write "<strong>Parts Grand Total Quantity: </strong>" & quantity_final3 & "<br />"
Response.Write "<strong>Parts Grand Total Cost: </strong>" & FormatCurrency(amount_final3, 2) & "<br />"
END IF

RS3.Close
objConn3.Close

The code worked fine, until I tried to make it print 6 columns wide, so I know the SQL and the rest of the ASP is working OK.

Edited by KamakaZ, 07 April 2010 - 09:42 PM.

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.


BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users