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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Intermediate
Jun 21, 2000

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Filtering a Recordset

If you have a recordset already created and want to filter it by some criteria, you can use the Filter property of the recordset to do it. Just change the recordset's Filter property to a WHERE clause and then set the recordset object to another recordset variable, like this:

 
Dim objRS, objFilter ' As ADODB.Recordset 
Dim dcnDB ' As ADODB.Connection 
Set dcnDB = Server.CreateObject("ADODB.Connection") 
dcnDB.Open "Some connection string" 
Set objRS = Server.CreateObject("ADODB.Recordset") 
objRS.Open "SELECT * FROM tblOrders", dcnDB, adOpenStatic 

objRS.Filter = "CustomerName Like %Smith%" 
Set objFilter = objRS 

Depending on how big the recordset is, you may want to simply 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're using in your filters.

Manoj K.
 
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