Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Apr 12, 2000

Filtering Recordset Data

Question:
After retrieving data into a recordset object, I want to filter this data. I tried using the objRs.filter method of ADO, but it doesn't seem to work.

This is my syntax:

objRSEmp.Filter = "EmpName like 'b*'"
EmpName is the name of the field in my SQL table.

I tried using a session variable, but after that I can't use any of the recordset's properties through the new variable. Can you help?

Answer:
Just setting the Filter property doesn't do it. You then have to set the recordset object to itself or another variable, like so:

objRSEmp.Filter = "EmpName like 'b*'"
Set objRSFiltered = objRSEmp
Depending on how big the recordset is, you may want to just do another query from the database. It will probably run faster, especially if you create a stored procedure to do the work for you. Also, make sure you have indexes on the fields that you are using in your filters.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date