Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Query using an array

New Here ,
Sep 13, 2006 Sep 13, 2006
Hi, I am attempting to return figures based on a file being passed to my ASP page, this file is a csv, which I split and enter the details into an array. This works, I have checked, it is when I am attempting to query the database using the array I am having problems, I have shown the code I attempted, but with no joy.

The database connection is working I have tried and tested it.

Any help will be appreciated, thanks.

<%
for i = Lbound(DZArray) to UBound(DZArray)

if DZArray(i) <> "" then '... Error check insure that no vbNull value comes through from the array
Set rsSearch = con.execute("SELECT * FROM MYEPopByNewAgeGroups WHERE MYEPopByNewAgeGroups.DataZone = '" & DZArray(i) & "'")

IF not rs.EOF then '... Error Check insure that a value is returned from the select statement
while not rsSearch.eof
%>
<tr>
<td><%= rsSearch("DataZone")%></td>
<td><%= rsSearch("Under 5")%></td>
<td><%= rsSearch("5-15")%></td>
<td><%= rsSearch("16-24")%></td>
</tr>
<%
rsSearch.movenext
wend
end if
%>
TOPICS
Server side applications
202
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2006 Sep 13, 2006
Not sure exactly what you're trying to accomplish here but here's an example of something similar I've done. This code loops through the array of submitted form check boxes and adds each one to my shopping cart.

<%
checkedProducts = Request.Form("ATCCheck")
checkedProductsSplit = Split(checkedProducts,",")
for i = LBound(checkedProductsSplit) to UBound(checkedProductsSplit)
%>

<%
Dim rsAddedItems
Dim rsAddedItems_cmd
Dim rsAddedItems_numRows

Set rsAddedItems_cmd = Server.CreateObject ("ADODB.Command")
rsAddedItems_cmd.ActiveConnection = MM_connKennysMDIData_STRING
rsAddedItems_cmd.CommandText = "SELECT kennysInventoryID, productDescription1, productID, productName, unitPrice, weight FROM products WHERE productID = "&checkedProductsSplit(i)&""
rsAddedItems_cmd.Prepared = true

Set rsAddedItems = rsAddedItems_cmd.Execute
rsAddedItems_numRows = 0
%>

<%
'Add item to shopping cart
%>

<%
Next
%>

<%
rsAddedItems.Close()
Set rsAddedItems = Nothing
%>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2006 Sep 13, 2006
LATEST
Looks like you might just be missing the Next that runs the loop...??
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines