1) Use the filter property.
2 You can create recordsets dynamically so you could:-
Declare a recordset variable
Instantiate the recordset
Loop through the fields collection of one of your recordsets to append
fields to your new recordset
Then loop through the records and fields of each recordset adding
records to your new recordset.
Alternatively use getrows to put the recordsets into arrays and then iterate
the arrays which might be faster.
> 1) Use the filter property.
> 2 You can create recordsets dynamically so you could:-
[quoted text clipped - 8 lines]
> iterate
> the arrays which might be faster.
Actually there is another way that is almost infinitely easier to code, and
is faster as well:
1. Filter recordset to desired subset
2. Persist the filtered recordset to an XML object
3. Open new recordset using XML object as source
' rs is assumed to be an open ADODB.Recordset
'
Dim xml As MSXML2.DOMDocument, rsSubset as ADODB.Recordset
Set xml = New MSXML2.DOMDocument
Set rsSubset = New ADODB.Recordset
rs.Filter = "[your conditions]"
rs.Save xml, adPersistXML ' save to IStream exposed by xml object
rsSubset.Open xml
As opened above, rsSubset is entirely disconnected from rs and its
underlying data. It can, however, be reconnected, by setting
rsSubset.ActiveConnection.
To combine rows from two recordsets into one, let's assume that xmlDest was
created using the technique above, to include the subset of rows from one of
the source recordsets, and xmlSrc contains the rows from the other source
recordset, that are to be combined.
Dim DestNode As IXMLDOMNode, SrcNode As IXMLDOMNode
Dim SrcNodeList As IXMLDOMNodeList
Set DestNode = xmlDest.selectSingleNode("xml/rs:data")
Set SrcNodeList = xmlSrc.selectNodes("xml/rs:data/z:row")
For Each SrcNode in SrcNodeList
DestNode.appendChild SrcNode.cloneNode(True)
Next
rsCombined.Open xmlDest
In most cases (read: all cases I have observed), moving rows as XML nodes is
appreciably faster than adding rows to a recordset object, and iterating
fields to copy rows from another -- in part I'm sure to all of the variant
overhead that's skipped.
Note that these source fragments are by no means all-inclusive -- for one
thing, if any inserts/updates/deletes have been performed on a source
recordset, the rows involved will be ignored by the node paths used above.
But if you're interested in manipulating persisted recordsets at the xml
level, it's a fair jumping-in point, at least.
-Mark
> Terry Kreft
>
[quoted text clipped - 11 lines]
>>
>> TIA
Terry Kreft - 12 Jul 2006 14:59 GMT
Ah yes, I have saved to a persisted file and reopened from there before but
had never thought of usiing a domdocument object directly, nice technique.
I wouldn't have thought this would work though, where you had summarised
data that you wanted to update as the summarised field would still be marked
as non-updatable, this is the reason why I would normally do something
similar to that which I posted.

Signature
Terry Kreft
> > 1) Use the filter property.
> > 2 You can create recordsets dynamically so you could:-
[quoted text clipped - 73 lines]
> >>
> >> TIA
Terry Kreft - 13 Jul 2006 08:11 GMT
I've tested this and found this to be the case (not surprisingly).
Still, obviously, as I said before, a nice technique.

Signature
Terry Kreft
<SNIP>
> I wouldn't have thought this would work though, where you had summarised
> data that you wanted to update as the summarised field would still be marked
[quoted text clipped - 84 lines]
> > >>
> > >> TIA
Mark J. McGinty - 30 Jul 2006 09:56 GMT
> I've tested this and found this to be the case (not surprisingly).
True enough, however, it is a trivial matter to change the relevant schema
node[s] to meet your needs:
Select the node "xml/s:Schema/s:ElementType", set its "rs:updatable"
attribute to "true"; this node will have one or more child "s:AttributeType"
nodes (one per field); locate the one[s] you want to make writable and set
the "rs:writeunknown" attribute to "true".
Another example of the "dirty tricks" that are possible: handling SQL Server
timestamp/rowversion (binary(8)) values is a serious PITA on the client
side; instead of dealing with safe arrays, I change the dt:type attribute
from "bin.hex" to "string". The advantages are many.
Of course by doing this sort of thing, you take responsibility for the
validity of the XML, ADO still has to be able to render it, and it is less
than forgiving if any mistakes are made. That not withstanding, I've found
it [persistance provider XML, that is] to be quite workable... effectively
it adds a great deal of range to what I can do with ADODB.Recordset.
> Still, obviously, as I said before, a nice technique.
Thanks! :-)
-Mark
> <SNIP>
>>
[quoted text clipped - 97 lines]
>> > >>
>> > >> TIA