Solved

vb6:ADO recorset assignment

Posted on 2007-11-16
8
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 143

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 143

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 143

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 143

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

735 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