0
Query using an array
New Here
,
/t5/dreamweaver-discussions/query-using-an-array/td-p/1004364
Sep 13, 2006
Sep 13, 2006
Copy link to clipboard
Copied
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
%>
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/query-using-an-array/m-p/1004365#M109976
Sep 13, 2006
Sep 13, 2006
Copy link to clipboard
Copied
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
%>
<%
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
%>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/dreamweaver-discussions/query-using-an-array/m-p/1004366#M109977
Sep 13, 2006
Sep 13, 2006
Copy link to clipboard
Copied
Looks like you might just be missing the Next that runs the
loop...??
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

