Solved

vb6:ADO recorset assignment

Posted on 2007-11-16
8
564 Views
Last Modified: 2013-12-26
I want to filter an ADO recordset, then assign the result and then clear the filter on the original recordset WITHOUT effecting the new recordset - VB6
0
Comment
Question by:mvanral
  • 4
  • 4
8 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20304154
please consider to use the recordset.clone method, and use the filter on the clone (or the original)
0
 

Author Comment

by:mvanral
ID: 20305829
i have tried this but it stays connected to the initial recordsdet. I want also to be able to marshall the filtered recordset accross the COM boundary. Problem is that the unfiltered trvordset can be huge, thousands of records and the filtered set that i want to work with will be under 20 records.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20306981
indeed, wanting to pass the filtered recordset will not reduce the data, as all the data is still part of the recordset, just the movexxx functions will skip them.

if the source data is huge, and the filtered data small, it is usually more effective to rerun the query with the added filter.
0
 

Author Comment

by:mvanral
ID: 20308689
i was trying to avoid going there. Are you saying that is the ONLY choice? I have tried clone, assignment to another RS and even a property bag, all keep the original rowset. there must be a way to just get the desired rows...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20308713
an alternative would be to loop yourself through the recordset, and create your own recordset with the data required.

here some sample code to create a recordset on the fly, and add 1 record to it

Dim rsrap As ADODB.Recordset
Set rsrap = CreateObject("ADODB.Recordset")

'create fields
rsrap.fields.Append "field1", adInteger
rsrap.fields.Append "field2", adInteger
rsrap.fields.Append "field3", adInteger
rsrap.fields.Append "field4", adInteger
rsrap.fields.Append "field5", adInteger
rsrap.fields.Append "field6", adInteger
rsrap.fields.Append "field7", adVarChar, 50

'put values in the fields
rsrap.Open


rsrap.AddNew

rsrap(0) = 0
rsrap(1) = 1
rsrap(2) = 2
rsrap(3) = 3
rsrap(4) = 4
rsrap(5) = 5
rsrap(6) = "tekst" & x

rsrap.Update

0
 

Author Comment

by:mvanral
ID: 20308738
i agree that this is better than the re-quering the original and is a workable choice - but is it the best available?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20308786
>but is it the best available?
well, that depends on what the filter is all about.
I usually avoid it the bigger the original set is, and the smaller the "filtered" data is, and if the data has to be most current as possible.

as said, you now know the options, you have to choose.
0
 

Author Closing Comment

by:mvanral
ID: 31409688
I appreciate the prompt help. Not the answer i wanted but i feel that i know my choices....
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now