PDA

View Full Version : ADO recordset search



rrrprogramer
10-21-2008, 06:14 AM
I'm using EXCEL 2003 writing VBA code and using Access database
In DAO, the Seek method for recordset, is used as a filter to search specific records within the current recordset. (Instead of running another SQL query in a database, I wrould rather do a search within the recordset)
In ADO, Seek method cannot be used with ADO. Is there a similar method to Seek that allows to search records within the ADO recordset??

Bob Phillips
10-21-2008, 06:21 AM
You can filter the recordset - http://www.devguru.com/technologies/ado/QuickRef/recordset_filter.html

Dr.K
10-21-2008, 11:13 AM
You can't SEEK, but you can FIND, FILTER and SORT.

FILTER and SORT work just like adding additional WHERE or ORDER BY clauses to the SQL.

FIND is a completely different beast: for one thing it only works on ONE column at a time, whereas FILTER conditions can be as complicated as any standard WHERE clause.

FILTER is generally much faster then FIND:


Although Find is appropriate in some situations, using it to locate records is generally very inefficient, both in terms of speed and memory use. Find works by examining each record in a Recordset for the criteria you give it after you have created the Recordset and retrieved all the data from your database. Retrieving lots of unwanted records, particularly down the wire from a server, when you are really interested in only a handful—or even worse, just one bit of data—creates a lot of unnecessary overhead. Unless you have a very compelling reason for using Find, I'd recommend using an alternative approach, like filtering your Recordset or using SQL, for serious performance gains.

http://articles.techrepublic.com.com/5100-10878_11-1045830.html


EDIT:
For some reason, I use this website for reference, even though the information in it is completely redundant to whats on MSDN.

http://www.w3schools.com/ado/ado_ref_recordset.asp