|
-
May 4th, 2004, 01:52 AM
#1
Thread Starter
New Member
wahhh, help me please
I am new to functions and arrays, and my brain is now officially jello... runny too long in the sun jello...
I need to dynamically create an array, sort of...
Here is the method that i am using for static content:
Code:
Function GetItemParameters(iItemID)
Dim aParameters
Select Case iItemID
Case 1
aParameters = Array("ItemID", "CategoryID", "15.00")
Case 2
aParameters = Array("ItemID", "CategoryID", "17.50")
Case 3
aParameters = Array("ItemID", "CategoryID", "35.00")
End Select
GetItemParameters = aParameters
End Function
However, I need to populate it from a database. This is for a shopping cart, and there is no way that i'm going to be able to list the items manually, because it can change dynamically. I can't find any tutorials to show me how to do that.
I can count the Item records for each Category (relational tables), however, i can't for the life of me figure out how to generate this case select statement dynamically.
this is the best that i've come up w/ and of course, it doesn't work:
Code:
Function GetItemParameters(iItemID)
i=0
j=CInt(objItemsRS.RecordCount-1)
Select Case iItemID
for i=i to j
Case CInt(i)
aParameters(i) = Array(objItemsRS("ItemID"),objItemsRS("CatID"), &_
objItemsRS("ItemHeader"),objItemsRS("ItemSubHeader"), &_
objItemsRS("ItemPrice"),objItemsRS("ItemSalePrice"), &_
objItemsRS("ItemImg"),objItemsRS("ItemSKU"))
Next
End Select
GetItemParameters = aParameters
End Function
can anyone help?
-
May 4th, 2004, 02:28 AM
#2
Junior Member
I may be missing something, but why not just loop through the recordset, checking the iItemID variable against the ItemID field in the database?
Something like:
VB Code:
objItemsRS.MoveFirst
Do Until objItemsRS.EOF
If objItemsRS.Fields("ItemID") = iItemID Then
' We now know which one they picked ...
' Grab the other information for this record
' from the recordset.
End If
objItemsRS.MoveNext
Loop
Hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|