Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exec select on recordset? Or other solution?

Status
Not open for further replies.

csteinhilber

Programmer
Aug 2, 2002
1,291
US
I'm using classic ASP/VBScript.
I have a module that builds up an in memory recordset (no DB is immediately available), like:
Code:
Const aVarChar = 200
Set rs = CreateObject("ADOR.Recordset")
rs.Fields.Append "id", aVarChar, 15
rs.Fields.Append "name", aVarChar, 50
rs.Fields.Append "img", aVarChar, 255
rs.Open
rs.AddNew
rs("id") = "id1"
rs("name") = "Name 1"
rs("img") = "/image/image1.jpg"
rs.Update
   :
I use this recordset to output a form that allows the user to select items (checkboxes).
Code:
<input type="checkbox" name="<%= rs.Fields.Item("id") %>" value="1" />
On the page that the form submits to, I'd like to load up the same in memory recordset, and then execute a select on it based on the selected checkboxes.
Something like:
Code:
Dim selectedItems
selectedItems = "'0'"
For Each Field In Request.Form
    fieldVal = Request.Form(Field)
    if Len(Trim(fieldVal)) > 0 then
       selectedItems=selectedItems & ",'" & Field & "'"
    end if
Next
After which selectedItems should have something like '0','1A34','4321','55E5'

Then I basically want to perform something like

SELECT * FROM {RS} WHERE ID IN (selectedItems)

But I can't find any documentation to suggest that I can execute SELECTs on recordsets that are already present in memory.

Anyone know if this is possible?

The only other solution I can think of is to loop through the all the rows in the recordset manually and check the row's ID against each of the IDs in the selectedItems list... but that seems tremendously inefficient and I'm hoping there's another solution I'm not thinking of.

Any ideas?

Thanks in advance!
-Carl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top