Re: MDAC Converting Dataset to XML



The "recordset" is a pointer to an already open recordset passed into the
function that does the conversion to XML. The XML is then passed to a
separate function to convert back to a recordset (mimicking the multi-tier
nature of the application).

The resulting XML has the invalid data.

I have fully converted your sample to read a static piece of XML, convert it
to a dataset then save to another XML object and the same issue occurs as
follows:

// Create an XML object and read in some valid XML...
xmlobjIN := CreateOleObject('MSXML2.DomDocument');
xmlobjIN.loadXML(Memo3.Text);

// Create an ADO Recordset and open the XML into it...
RS := CreateOleObject('ADODB.Recordset');
RS.Open(xmlobjIN);

// "Join" this recordset to a data-aware component (to see results on
screen)...
ADODataSet1.Recordset := _RecordSet(IUnknown(RS));

// Create an XML object and save the recordset to it...
xmlobjOUT := CreateOleObject('MSXML2.DomDocument');
RS.Save(xmlobjOUT, pfXML);

// Show the XML on a form...
Memo1.Text := xmlobjOUT.xml;


Note, the line "ADODataSet1.Recordset := _RecordSet(IUnknown(RS));"
demonstrates on screen that a valid recordset has been read from plain XML,
this didn't involve access to the database. Both the output XML and the data
grid containing the results show the invalid data.

Stewart



"Bob Barrows [MVP]" wrote:

Stewart (Oraculum) wrote:
OK, I think I have reproduced your code in Delphi as follows:

if Recordset = nil then Exit;
try
RS := CreateOleObject('ADODB.Recordset');
RS := Recordset.Recordset;

xmlobj := CreateOleObject('MSXML2.DomDocument');

if Form2.RadioButton1.Checked then
RS.Save(xmlobj, pfXML)
else
RS.Save(xmlobj, pfADTG);
Result := xmlobj.xml;
finally
Stream.Free;
RS := UNASSIGNED;
end;

As you see didn't require too much change and the results are the
same, however trying this method via ADTG fails but I think I would
expect that seeing as its using an XML object explicitly.

I don't see the key part, which is opening the recordset on the xml file
created by the successful rs.Save.

In fact, I don't see where you open this recordset at all ...

The goal is to be able to reproduce the symptom without having access to
your database.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



.