473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

simple retrieving value using array

Fary4u
273 100+


attach file contains database table,

retrieving value using multiple array, no problem retrieving 1st values but when i'm trying to retrieving 2nd array value giving errer.

here is my coding
Expand|Select|Wrap|Line Numbers
  1. <%
  2. s1 = "S"
  3. Set Conn = Server.CreateObject("ADODB.Connection")
  4. Conn.Open ConString
  5. SQL2 = "SELECT stock, color_id FROM PRODUCT_COLOURS WHERE prod_id = '" & sear & "' and sizes = '" & s1 & "'" 
  6. set rsSizes = Server.CreateObject("ADODB.RecordSet")
  7. set rsSizes = Conn.Execute(SQL2)
  8. countS = 0
  9. dim strsize()
  10. while not rsSizes.EOF
  11. if countS = 0 then
  12.     redim strsize(0)
  13.     strsize(countS) = rsSizes("stock")
  14.     strsize(countS) = rsSizes("color_id")
  15. else
  16.     redim preserve strsize(countS)
  17.     strsize(countS) = rsSizes("stock")
  18.     strsize(countS) = rsSizes("color_id")
  19. end if
  20. rsSizes.MoveNext
  21. countS = countS + 1
  22. Wend
  23. ts = ubound(strsize)
  24. %>    
  25. <tr>
  26. <td class="style5"><b>Small :</b></td>
  27. <td><input type="text" name="black_small" value="<%
  28.         for Si = 0 to ts
  29.         If strsize(Si) = "Black" then
  30.             response.write strsize(Si)
  31.         End if
  32.         next
  33.         %>"/>
  34.         </td>
  35. <td><input type="text" name="blue_small" value="<%
  36.         for Si = 0 to ts
  37.         If strsize(Si) = "Blue" then
  38.             response.write strsize(Si)
  39.         End if
  40.         next
  41.         %>"/></td>
  42. <td><input type="text" name="green_small" value="<%
  43.         for Si = 0 to ts
  44.         If strsize(Si) = "Green" then
  45.             response.write strsize(Si)
  46.         End if
  47.         next
  48.         %>"/></td>
  49. </td></tr></table>
  50.  
Sep 24 '10 #1
3 1655
Fary4u
273 100+
latest changes word fine again but value not cross ponding.
Expand|Select|Wrap|Line Numbers
  1. s1 = "S"
  2. Set Conn = Server.CreateObject("ADODB.Connection")
  3. Conn.Open ConString
  4. ' SELECT DISTINCT color_id FROM PRODUCT_COLOURS WHERE prod_id = '" & sear & "'"
  5. SQL2 = "SELECT stock FROM PRODUCT_COLOURS WHERE prod_id = '" & sear & "' and sizes = '" & s1 & "'"
  6. SQL3 = "SELECT color_id FROM PRODUCT_COLOURS WHERE prod_id = '" & sear & "' and sizes = '" & s1 & "'"
  7. set rsSizes = Server.CreateObject("ADODB.RecordSet")
  8. set rsSizes = Conn.Execute(SQL2)
  9. set rsSizes3 = Server.CreateObject("ADODB.RecordSet")
  10. set rsSizes3 = Conn.Execute(SQL3)
  11. countS = 0
  12. countT = 0
  13. dim strsize()
  14. dim strsizeT()
  15.  
  16. while not rsSizes.EOF
  17. if countS = 0 then
  18.     redim strsize(0)
  19.     strsize(countS) = rsSizes("stock")
  20. else
  21.     redim preserve strsize(countS)
  22.     strsize(countS) = rsSizes("stock")
  23. end if
  24. rsSizes.MoveNext
  25. countS = countS + 1
  26. Wend
  27.  
  28. while not rsSizes3.EOF
  29. if countT = 0 then
  30.     redim strsizeT(0)
  31.     strsizeT(countT) = rsSizes3("color_id")
  32. else
  33.     redim preserve strsizeT(countT)
  34.     strsizeT(countT) = rsSizes3("color_id")
  35. end if
  36. rsSizes3.MoveNext
  37. countT = countT + 1
  38. Wend
  39.  
  40. ts = ubound(strsize)
  41. tT = ubound(strsizeT)
  42. %>    
  43.     <tr>
  44.         <td class="style5" style="text-align: right"><b>Small :</b></td>
  45.         <td class="style5"><input type="text" name="black_small" size="3" value="<%
  46.         for Si = 0 to tT
  47.         If strsizeT(Si) = "Black" then
  48.         response.write strsize(Si)
  49.             for T = 0 to ts
  50.                 response.write strsize(ts)
  51.             next
  52.         End if
  53.         next
  54.         %>"/>
  55.         </td>
  56.         <td class="style5"><input type="text" name="blue_small" size="3" value="<%
  57.         for Si = 0 to tT
  58.             for T = 0 to ts
  59.         If strsizeT(Si) = "Blue" then
  60.         response.write strsize(Si)
  61.                 response.write strsize(ts)
  62.         End if
  63.             next
  64.         next
  65.         %>"/></td>
  66.         <td class="style5"><input type="text" name="green_small" size="3" value="<%
  67.         for Si = 0 to tT
  68.         If strsizeT(Si) = "Green" then
  69.         response.write strsize(Si)
  70.             for T = 0 to ts
  71.                 response.write strsize(ts)
  72.             next
  73.         End if
  74.         next
  75.         %>"/>
  76.  
Sep 24 '10 #2
Fary4u
273 100+
any possibility to work out ?
Sep 28 '10 #3
Nicodemas
164 Expert 100+
Will this help? My example uses a FOR loop after converting your Record Set into a 2d array (for better performance). My example might not order the results as you prefer, so I suggest that if you cannot use my suggestion as is, that you augment your SQL to perform an ORDER BY so as to order it explicitly how you want.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim s1, Conn, SQL2, rsSizes, countS, arrSizes
  3.  
  4. s1 = "S" 
  5. Set Conn = Server.CreateObject("ADODB.Connection") 
  6. Conn.Open ConString 
  7. SQL2 = "SELECT stock, color_id FROM PRODUCT_COLOURS WHERE prod_id = '" & sear & "' and sizes = '" & s1 & "'"  
  8. set rsSizes = Server.CreateObject("ADODB.RecordSet") 
  9. set rsSizes = Conn.Execute(SQL2) 
  10. countS = 0 
  11.  
  12. 'convert the recordset to a 2d array for lower system overhead
  13. if not rsSizes.EOF then
  14.    arrSizes = rsSizes.getrows
  15.    set rsSizes = nothing%>
  16.  
  17.    <tr> 
  18.       <td class="style5"><b>Small :</b></td><%
  19.       'use a FOR loop to cycle through the values returned by the query
  20.       for countS = 0 to ubound(arrSizes, 2)%>     
  21.  
  22.          intStock = arrSizes(0, countS)
  23.          strColor = arrSizes(1, countS)
  24.  
  25.          response.write "<td>" & strColor & ": "
  26.          response.write "<input type=""text"" name="""& lcase(strColor) &"_small"" value="""& intStock &""" />"
  27.          response.write "</td>"  
  28.       next%>
  29.    </tr><%
  30. end if
  31.  
  32. Conn.close
  33. set Conn = nothing
  34. %>
Sep 29 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Susan Watters via .NET 247 | last post by:
I'm having trouble with what should seem like an obviously easy task. I've bound a text box with data from a data table (dt) and the correct value is placed into the text box: ...
2
by: Ros | last post by:
Peeps, I need help with trying to find a value in array of arrays. Public Module myModule Private Site_Access() As Array Property Set_SA() Get Return Site_Access End Get
2
by: Kevin Humphreys | last post by:
Hi There, Is it possible to retrieve a client side control value using server VB.NET? Thanks, Kevin.
0
by: sachin10 | last post by:
hi i m sachin, i m new to VB programming.i face some problem regarding the sorting of text file contents using arrays.text file have data in the format as below seq...
2
by: palani12kumar | last post by:
Hi i've implemented a linear Queue using array. But i've been struck up with a doubt!!!!! Let me tell my problem with an example so that it can be clear. Size of the Queue(array) is 5. im...
1
shoonya
by: shoonya | last post by:
i am using array as a data type in my db .... ( sequence integer ) ; and it stores a value let {1,2,3,4,5}
1
by: sksksk | last post by:
I want to achieve the following process in the smarty for $item one i should be able to get the value using loop.index, but without any luck. any help is appreciated. <?php for ($i = 1; $i...
1
by: vishwa Ram | last post by:
Hi ScriptFamily, I need to remove a duplicate value in array. Any specific method available in perl. pls suggest Regards Raam
2
by: priyanka1915 | last post by:
helloo, I have to retrive the data from database and then check that value my column in database is CATEGORY ------------------------------- COMMODITY COMMODITY COMMODITY
14
by: KK | last post by:
Dear All I have a small problem with using as operator on value type array. Here is an example what I am trying to do. using System; using System.Collections.Generic; using System.Text;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.