Re: Insert a record to a specific row

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Lou" <lou.garvin@xxxxxxxxxxx> wrote in message
news:eYoQr67FHHA.4804@xxxxxxxxxxxxxxxxxxxxxxx
I am using disconnected recordsets and binding the recordset to a grid.
I need to insert a record into the recordset to a specific position(row).
How can I achieve this?

Assuming the recordset is unsorted on the client side (i.e., rows are
displayed in the order they were returned by the data source) the only way I
can think of to achieve this is to persist the recordset to XML, and
position the new row in the node list at its desired location.

The operative node list would be that returned by
rsxml.selectSingleNode("xml/rs:data").children. You can expect, having just
inserted a record into a recordset, that its corresponding <rs:insert><z:row
..../></rs:insert> node will be at the end of the node list resolved. Remove
that node, saving it to an object variable, locate the desired position in
the node list, then insert the node relative to that position.

Then create another recordset object, open it using the xml object as the
source parameter, set the grid's DataSource to that recordset, and call the
grid's ReBind method. If the number of rows is reasonably small the effect
should be reasonably seamless.

Note that you will not be able to edit the new record until after it has
been sent-up to the server, because it will not have access to its identity
value until after that.

Also note that you will not find this technique in any MS-authored "best
practices" lists (in fact I'm fairly certain they specifically advise
against it.) OTOH, it's worth pointing out that absolutely any state in
which you might find a [disconnected] recordset or any of its fields, can be
manufactured at the XML level. This effectively makes the recordset's
behavior extensible in a moderate range of scenarios... due care is advised.


-Mark





-Lou



.



Relevant Pages

  • Re: How to Programmatically Export as XML & SXL
    ... Unfortunately, I've had precious little to do with XML in Access, so I'm ... you use the ADO Recordset object's Save ... >>Dim rs As ADODB.Recordset ... >>Dim strADTGFile As String ...
    (microsoft.public.access.externaldata)
  • Re: MDAC Converting Dataset to XML
    ... I hadn't realised there was a later version of MDAC than the one we had ... recordset is fine, the code that does this is a mirror of the conversion to ... XML and for completeness I include a copy (albeit ... Can you reproduce the symptom by saving the first piece of xml to a file, ...
    (microsoft.public.data.ado)
  • Re: Database + dll
    ... You can include an XML or ADTG persisted Recordset with the ... XML can be compiled into a DLL as a resource, ... copied to a stream first anyway (not that the recordset would alter the ... It's a simple matter of creating a custom resource type from an XML file at ...
    (microsoft.public.vb.database.ado)
  • Re: adodb.recordset.save and back
    ... persisted XML file back into recordset, ... Dim Rs as New ADODB.Recordset ... and when you reconnect it to the database you get the error ...
    (microsoft.public.data.ado)
  • Cant Update XML Recordset
    ... We return an updated XML recordset from a web service call. ... Dim objRs As New ADODB.Recordset ... Set objXML = CreateObject ...
    (microsoft.public.data.ado)