Re: compare 2 recordsets
- From: "RB Smissaert" <bartsmissaert@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Sep 2007 13:22:01 +0100
This seems to be working and is a lot faster:
230 rsNode.MoveFirst
240 Do While rsNode.EOF = False
250 Do While rsParentNode.Fields(lParentField) < rsNode.Fields(lNodeField) And _
rsParentNode.EOF = False
260 rsParentNode.MoveNext
270 If rsParentNode.Fields(lParentField) > rsNode.Fields(lNodeField) Then
280 rsNode.Delete adAffectCurrent
290 rsParentNode.MovePrevious
300 Exit Do
310 End If
320 Loop
330 rsNode.MoveNext
340 Loop
'this is important, otherwise rs.EOF will be true and nil will be moved to SQLite
350 rsNode.MoveFirst
I never worked much with recordsets and I realise now I needed some different settings to
do this and also need to disconnect the recordset.
RBS
"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in message news:eaTFtPjAIHA.4584@xxxxxxxxxxxxxxxxxxxxxxx
RB Smissaert wrote:What would be the best (fastest) way to do this:Why are you using recordsets for this? Are the recordsets from different databases?
I have 2 ADO recordsets say A and B.
They both have a common field, say ID
Now I need to delete all the records in recordset A where
the value in the field ID is not found in the field in recordset B.
These are values of the datatype Long.
The ID field will be sorted ascending in both recordsets.
Now, I could do this with a double loop, but that could be a bit slow
and I wonder if this could be done better with a filter or find.
If not, this is a job for SQL.
If so, there's no alternative to looping through one of them, but you can use Filter to get the corresponding records in the other recordset.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- References:
- compare 2 recordsets
- From: RB Smissaert
- Re: compare 2 recordsets
- From: Bob Barrows [MVP]
- compare 2 recordsets
- Prev by Date: Re: compare 2 recordsets
- Next by Date: Re: compare 2 recordsets
- Previous by thread: Re: compare 2 recordsets
- Index(es):
Relevant Pages
|
|