Solved

vb6:ADO recorset assignment

Posted on 2007-11-16
8
566 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

786 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