Solved

vb6:ADO recorset assignment

Posted on 2007-11-16
8
565 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now