Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

Discuss "loop addition problem" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old August 26th, 2008, 03:38 PM
Barn Frequenter

 
Join Date: Mar 2008
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default loop addition problem

hi,

I have a problem in my code

I have it in such a way where the user can select a size and then add different colors and logos to the size

so right now the user select size as "S"
then he selects 2 colors

Brown
Red

Brown he selects one logo -- RS logo
Red he selects 2 logo -- DFlogo, RS logo

but it only adds Red color and DFlogo and not Rs logo for red color it doesnt add brown logo in the table also

can someone tell me whats wrong with my loop

todd
Code:
<!--#include file="Loader.asp"-->
<%
  Response.Buffer = True
    Set load = new Loader
     load.initialize
    
    fileData = load.getFileData("file")
    fileName = LCase(load.getFileName("file"))
    filePath = load.getFilePath("file")
    filePathComplete = load.getFilePathComplete("file")
    fileSize = load.getFileSize("file")
    fileSizeTranslated = load.getFileSizeTranslated("file")
    contentType = load.getContentType("file")
    fileData1 = load.getFileData("file1")
    fileName1 = LCase(load.getFileName("file1"))
    filePath1 = load.getFilePath("file1")
    filePathComplete1 = load.getFilePathComplete("file1")
    fileSize1 = load.getFileSize("file1")
    fileSizeTranslated1 = load.getFileSizeTranslated("file1")
    contentType1 = load.getContentType("file1")
    fileData2 = load.getFileData("file2")
    fileName2 = LCase(load.getFileName("file2"))
    filePath2 = load.getFilePath("file2")
    filePathComplete2 = load.getFilePathComplete("file2")
    fileSize2 = load.getFileSize("file2")
    fileSizeTranslated2 = load.getFileSizeTranslated("file2")
    contentType2 = load.getContentType("file2")
    countElements = load.Count
    cat = load.getValue("cat")
    subcat = load.getValue("subcat")
    txtisbn = load.getValue("txtisbn")
    txtitem = load.getValue("txtitem")
    txtchk = load.getValue("txtchk")
    txtprice = load.getValue("txtprice")
    txtmemberprice = load.getValue("txtmemberprice")
    txtkeywords = load.getValue("txtkeywords")
    txtdescription = load.getValue("txtdescription")
    date1 = load.getValue("date1")
    userip = load.getValue("userip")
      size = load.getValue("size")
size = Split(trim(size),",") 
color = load.getValue("color")
logo = load.getValue("logo")
color = Split(trim(color),",") 
logo = Split(trim(logo),",") 

Set load = Nothing

Set rsprodcheck = Server.CreateObject("ADODB.Recordset")
sqlprodcheck="Select *From Products1 where Sub_Item='" & txtchk & "'"
rsprodcheck.Open sqlprodcheck, connStr, 2, 2

If not rsprodcheck.Eof then

Response.write "This item already exists"

Else

Set rscat= Server.CreateObject("adodb.RecordSet")
strcat = "Select Sub_Id from Sub_Categories where Cat_Id = '" & cat & "' and Sub_Cat_Name='" & subcat & "'"
rscat.Open strcat, connStr, 2, 2

subid=rscat("Sub_Id")

       Set rsprodadd = Server.CreateObject("ADODB.Recordset")
        sqlprodadd="Select * From Products1"
        rsprodadd.Open sqlprodadd, connStr, 2, 2
        Featured="No"
		Specials="No"
		InStore="Yes"
		  
		  rsprodadd.AddNew
        
		  rsprodadd("Cat_Id") =  cat 
		  rsprodadd("Sub_Id") = subid  
		  rsprodadd("Product_Code") = txtisbn
          rsprodadd("Sub_Item") = txtitem
          rsprodadd("Cover_Picture").AppendChunk fileData
          rsprodadd("Large_Picture").AppendChunk fileData1
		  rsprodadd("Store_Picture").AppendChunk fileData2
          rsprodadd("Featured") = Featured  
		  rsprodadd("Specials") = Specials
          rsprodadd("InStore") = InStore
          rsprodadd("IP_Address") = userip
		  rsprodadd("Added_By") = adminname
		  rsprodadd("DateTimeAdded") = date1
          rsprodadd.Update
  			 
        rsprodadd.Close
        Set rsprodadd = Nothing


 sqlprodid="Select Max(Product_Id) as Newest From Products1 where Sub_Item='" & txtchk & "'"
 Set RecSet = connStr.Execute(sqlprodid)
 ID = RecSet("Newest")
 RecSet.Close()




 Dim salePrice,instoring
instoring="Yes"
 salePrice="0.00"

Set rsprice = Server.CreateObject("ADODB.Recordset")
sqlprice="Select * From Products_Price"
rsprice.Open sqlprice, connStr, 2, 2


  rsprice.AddNew
        
		  rsprice("Product_Id") = ID  
		  rsprice("Price") = txtprice
          rsprice("Member_Price") = txtmemberprice
          rsprice("Sale_Price") = salePrice  
		  rsprice("InStore") = instoring
          rsprice("IP_Address") = userip
          rsprice("Added_By") = adminname  
		  rsprice("DateTimeAdded") = date1  

           rsprice.Update
           rsprice.Close
          Set rsprice = Nothing
 

Set rsdesc = Server.CreateObject("ADODB.Recordset")
sqldesc="Select * From Product_Description"
rsdesc.Open sqldesc, connStr, 2, 2


  rsdesc.AddNew
        
		  rsdesc("Product_Id") = ID  
		  rsdesc("Keywords") = txtkeywords
          rsdesc("Description") = txtdescription
          rsdesc("InStore") = InStore  
		  rsdesc("IP_Address") = userip
          rsdesc("Added_By") = adminname  
		  rsdesc("DateTimeAdded") = date1 

           rsdesc.Update
           rsdesc.Close
          Set rsdesc = Nothing

Dim sqlproddetails,rsproddetails
Dim i,j,k,m,n
Dim arrColor, arrLogo  
Dim sTempSize, sTempColor, sTempLogo

Set rsproddetails = Server.CreateObject("ADODB.Recordset")
  sqlproddetails="Select * From Products_Details"
  rsproddetails.Open sqlproddetails, connStr, 2, 2
  
  For i=0 to UBound(size)
	sTempSize=""
	If Trim(size(i)) = "None" then
			sTempSize="None"
			stempColor="None"
			sTempLogo="None"
			rsproddetails.AddNew
			rsproddetails("Product_Id") = ID  
		 	rsproddetails("Sizes") = sTempSize
 			rsProddetails("Color")=sTempColor
			rsProddetails("logo")=sTempLogo
			rsProddetails("Qty_Hand")="0"
						rsProddetails("InStore") = InStore 
                        rsProddetails("IP_Address") = userip
                        rsProddetails("Added_By") = adminname  
		        rsProddetails("DateTimeAdded") = date1 
			rsproddetails.Update

	End if

	If Trim(size(i))<> "" then
		sTempSize=trim(size(i))
		For j= 0 to UBound(color)
			sTempCOlor=""
			If trim(color(j)) <> "" then
				sTempColor=Mid(Trim(color(j)),Instr(1,trim(color(j)),"#")+1)
				Response.Write sTempColor &"<br/>"
				Response.Write (Mid(Trim(color(j)),1,Instr(1,trim(color(j)),"#")-1))
				If Mid(Trim(color(j)),1,Instr(1,trim(color(j)),"#")-1)=sTempSize then
					For k= 0 to UBound(logo)
						sTempLogo=""
						if Trim(logo(k)) <> "" then
							sTempLogo=Mid(Trim(logo(k)),(InstrRev(trim(logo(k)),"#",-1))+1)
							Response.Write sTempLogo & "<br>"
'Response.Write
'Mid(Trim(logo(k)),(Instr(1,trim(logo(k)),"#")+1),(InstrRev(trim(logo(k)),"#",-1)-(Instr(1,trim(logo(k)),"#")+1)))
If Mid(Trim(logo(k)),(Instr(1,trim(logo(k)),"#")+1),(InstrRev(trim(logo(k)),"#",-1)-(Instr(1,trim(logo(k)),"#")+1)))= sTempColor then
								If not CheckDuplicateProduct(stempsize,sTempColor,sTempLogo) then
									rsproddetails.AddNew
								 		rsproddetails("Product_Id") = ID  
		 								rsproddetails("Sizes") = sTempSize
 										rsProddetails("Color")=sTempColor
										rsProddetails("logo")=sTempLogo
										rsProddetails("InStore") = InStore 
                                        rsProddetails("IP_Address") = userip
                                        rsProddetails("Added_By") = adminname  
		                                rsProddetails("DateTimeAdded") = date1 
										
									rsproddetails.Update
								End if
							End if
						End if
					Next
				End if
			End if
		Next
	End if		
  Next
 		   rsproddetails.Close
 		Set  rsproddetails = Nothing

		Response.write "Item added Successfully"
%>


<%
Function CheckDuplicateProduct(size,color,logo)
	Dim sqlDuplicateProduct,rsDuplicateProduct

  Set rsDuplicateProduct = Server.CreateObject("ADODB.Recordset")
sqlDuplicateProduct="Select * From Products_Details where Sizes='" & size & "'" & " and Color='" & color & "'" & " and Logo='" & logo & "'"
  rsDuplicateProduct.Open sqlDuplicateProduct, connStr,3,2
  	Response.write rsDuplicateProduct.RecordCount 

	If rsDuplicateProduct.RecordCount >= 1 then
	    Response.write "I am here "
		CheckDuplicateProduct= true	
	Else
		    Response.write "I am not here "
		CheckDuplicateProduct=false
	End if

End Function
%>
<%
End if
%>
Reply With Quote
Sponsored Links
  #2  
Old August 26th, 2008, 05:07 PM
Shadow Wizard's Avatar
Ask Me About Dragons :D

 
Join Date: Jul 2008
Posts: 23
Thanks: 0
Thanked 4 Times in 4 Posts
Blog Entries: 1
Rep Power: 1
Shadow Wizard is on a distinguished road

Awards Showcase
Microsoft .Net Classic ASP JavaScript 
Total Awards: 3

Default

what loop exactly?
please post or make bold relevant part in your code.
Reply With Quote
  #3  
Old August 26th, 2008, 08:44 PM
Barn Frequenter

 
Join Date: Mar 2008
Posts: 197
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default

Shadow here is the code which adds the size, color, logo to the table

thanks for ur help

Code:
 For i=0 to UBound(size)
	sTempSize=""
	If Trim(size(i)) = "None" then
			sTempSize="None"
			stempColor="None"
			sTempLogo="None"
			rsproddetails.AddNew
			rsproddetails("Product_Id") = ID  
		 	rsproddetails("Sizes") = sTempSize
 			rsProddetails("Color")=sTempColor
			rsProddetails("logo")=sTempLogo
			rsProddetails("Qty_Hand")="0"
						rsProddetails("InStore") = InStore 
                        rsProddetails("IP_Address") = userip
                        rsProddetails("Added_By") = adminname  
		        rsProddetails("DateTimeAdded") = date1 
			rsproddetails.Update

	End if

	If Trim(size(i))<> "" then
		sTempSize=trim(size(i))
		For j= 0 to UBound(color)
			sTempCOlor=""
			If trim(color(j)) <> "" then
				sTempColor=Mid(Trim(color(j)),Instr(1,trim(color(j)),"#")+1)
				Response.Write sTempColor &"<br/>"
				Response.Write (Mid(Trim(color(j)),1,Instr(1,trim(color(j)),"#")-1))
				If Mid(Trim(color(j)),1,Instr(1,trim(color(j)),"#")-1)=sTempSize then
					For k= 0 to UBound(logo)
						sTempLogo=""
						if Trim(logo(k)) <> "" then
							sTempLogo=Mid(Trim(logo(k)),(InstrRev(trim(logo(k)),"#",-1))+1)
							Response.Write sTempLogo & "<br>"
'Response.Write
'Mid(Trim(logo(k)),(Instr(1,trim(logo(k)),"#")+1),(InstrRev(trim(logo(k)),"#",-1)-(Instr(1,trim(logo(k)),"#")+1)))
If Mid(Trim(logo(k)),(Instr(1,trim(logo(k)),"#")+1),(InstrRev(trim(logo(k)),"#",-1)-(Instr(1,trim(logo(k)),"#")+1)))= sTempColor then
								If not CheckDuplicateProduct(stempsize,sTempColor,sTempLogo) then
									rsproddetails.AddNew
								 		rsproddetails("Product_Id") = ID  
		 								rsproddetails("Sizes") = sTempSize
 										rsProddetails("Color")=sTempColor
										rsProddetails("logo")=sTempLogo
										rsProddetails("InStore") = InStore 
                                        rsProddetails("IP_Address") = userip
                                        rsProddetails("Added_By") = adminname  
		                                rsProddetails("DateTimeAdded") = date1 
										
									rsproddetails.Update
								End if
							End if
						End if
					Next
				End if
			End if
		Next
	End if		
  Next
Reply With Quote
  #4  
Old August 27th, 2008, 04:43 AM
Shadow Wizard's Avatar
Ask Me About Dragons :D

 
Join Date: Jul 2008
Posts: 23
Thanks: 0
Thanked 4 Times in 4 Posts
Blog Entries: 1
Rep Power: 1
Shadow Wizard is on a distinguished road

Awards Showcase
Microsoft .Net Classic ASP JavaScript 
Total Awards: 3

Default

what you see on the screen? do you see what you expect? if not, what
is missing?
maybe this part:
Code:
If Mid(Trim(logo(k)),(Instr(1,trim(logo(k)),"#")+1),(InstrRev(trim(logo(k)),"#",-1)-(Instr(1,trim(logo(k)),"#")+1)))= sTempColor then
is always False, you need to debug this and see what's the root of the problem.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loop update statement peebman2000 SQL Development 2 August 7th, 2008 10:04 AM
Loop / Summary help Rebelle ASP Development 7 April 11th, 2008 10:12 AM


All times are GMT -4. The time now is 04:37 PM.



Content Relevant URLs by vBSEO 3.2.0