Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb6:ADO recorset assignment

Posted on 2007-11-16
8
Medium Priority
?
570 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
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!

 

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 2000 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

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!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

664 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