Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO Recordset.Find versus Recordset.Open
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00404383
Message ID:
00404482
Views:
11
Hmmmm. I'm thinking the explicit select on primary key would be faster. The Find method of the ADO recordset only searches in one direction - Forward or Backward. When you find a particular record using Find, the record pointer is set to that record. Your next Find will search from that point. For what you are trying to do that obviously doesn't help since the value you want may be "behind" the record pointer.

The way you make the Find do what you want it to do is to provide the SearchDirection and Start parameters like this:

oRS.Find "pkey = 1111", SearchDirection:=adSearchForward, Start:=adBookmarkFirst

Now this would effectively be the same as:

oRS.MoveFirst
oRS.Find "pkey = 1111"

Two ADO operations for the price of one! What a deal! Well, not so much. Basically you're just doing a SCAN. If your ADO connection stays open thoughout the loop's iterations I think that doing an explicit query against the primary key would be faster. Of course on such a small recordset the difference may be negligible.

>Hey folks,
>
>General ADO question here: Is there a significant speed difference between using the Recordset.Find method on a recordset with about a dozen rows with a single key field created using .Open("SELECT * from table") and .Open("SELECT * FROM table WHERE pkey = 1111")?
>
>I ask this in the context of a lookup table that needs to be hit up about 100 times in a big loop. Right now, everything is "Open" where I SELECT for the single key and I'm thinking of changing that if some benefit will be derived by opening the entire table all at once and using Find in the loop.
>
>It's a big programming task and I was looking for some informed opinions first.
>
>Thanks!
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Previous
Reply
Map
View

Click here to load this message in the networking platform