Board index » delphi » ADO Recordset and XML DOM

ADO Recordset and XML DOM

Hi,
I need to save the recordset into a DOM document object as explained into
MSDN documentation:

Dim xDOM As New MSXML.DOMDocument
Dim rsXML As New ADODB.Recordset
Dim sSQL As String, sConn As String

sSQL = "SELECT customerid, companyname, contactname FROM customers"
sConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files" & _
        "\Common Files\System\msadc\samples\NWind.mdb"
rsXML.Open sSQL, sConn
rsXML.Save xDOM, adPersistXML   'Save Recordset directly into a DOM tree.

In Delphi should be:

var
  xmlObj: IXMLDOMDocument;
  rs: _Recordset;
begin
  xmlObj := CoDOMDocument.Create;
  tbFunctions.Active := true;
  rs := (tbFunctions.Recordset) as ADODB_TLB._Recordset;
  rs.Save(xmlObj, adPersistXML);

Theres an error message where it's expected a widestring into save method.
So, how can I save into a dom document structure the content of my recordset
(without late binding instancing) ?

Thanks
Pierre

 

Re:ADO Recordset and XML DOM


Quote
Pierre Greborio <pie...@pierregreborio.it> wrote in message

news:3960e1e9@dnews...

Quote
> I need to save the recordset into a DOM document object as explained into
> MSDN documentation:

Do you have a link to where you saw that article?  The Save method as defined in
the ADO 2.1 interface only takes a WideString filename parameter.  I think you
have to use a variant dispatch to get it to work.

try:

   Variant(rs).Save(xmlObj, adPersistXML);

Good luck.

Mark

Re:ADO Recordset and XML DOM


Quote
> Do you have a link to where you saw that article?  The Save method as
defined in
> the ADO 2.1 interface only takes a WideString filename parameter.  I think
you
> have to use a variant dispatch to get it to work.

> try:

>    Variant(rs).Save(xmlObj, adPersistXML);

It doesn't works...type mismatch. I think that's an ADO 2.5 feature.

The article ai found on MSDN library to
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2000APR\10
33. Looks with search to "recordset and DOM".

Pierre

Re:ADO Recordset and XML DOM


ADODB and ADOInt modules in Delphi 5 are based on
ADO 2.1, while saving to streams was only added
to ADO in version 2.5. I have not seen patches
from Borland that would upgrade their
implementation to 2.5.

If you import ADO 2.5, Delphi will create
ADODB_TLB file which you can browse to see all
the differences.

Your options are: patch ADODB and ADOInt to match
ADO 2.5, or wait for Borland to issue a patch.

I'm in exactly same position as you are, trying
to save ADO Recordset into XML without using
external files, and I'm currently considering
same options.

-Anatoli

In article <39638e99@dnews>,
  "Pierre Greborio" <pie...@pierregreborio.it>
wrote:

Quote
> > Do you have a link to where you saw that

article?  The Save method as
Quote
> defined in
> > the ADO 2.1 interface only takes a WideString

filename parameter.  I think
Quote
> you
> > have to use a variant dispatch to get it to
work.

> > try:

> >    Variant(rs).Save(xmlObj, adPersistXML);

> It doesn't works...type mismatch. I think

that's an ADO 2.5 feature.
Quote

> The article ai found on MSDN library to
> mk:@MSITStore:C:\Program%20Files\Microsoft%

20Visual%20Studio\MSDN\2000APR\10

Quote
> 33. Looks with search to "recordset and DOM".

> Pierre

Sent via Deja.com http://www.deja.com/
Before you buy.

Re:ADO Recordset and XML DOM


Correction to my previous posting.

You can import ADO 2.5, resulting in ADODB_TLB file creation, then put
it into your Uses section after ADODB and ADOInt, and write code like
my sample below to save recordset directly into DOM. Alternatively, you
can save it to any object that supports IStream, and do whatever you
desire with the resulting buffer. I've just tried it, and it worked
beautifully.

Until Borland fixes ADODB and ADOInt to comply with ADO 2.5, that's the
best I can think of.

var
  dDocument: DOMDocument;
begin
  dDocument := CoDOMDocument.Create;
  try
    dmMyDataModule.adsMyADODataset.Open;
    ADODB_TLB._Recordset(dmMyDataModule.adsMyADODataset.Recordset).
      Save( dDocument, ADODB_TLB.adPersistXML );
  finally
    dDocument := nil;
  end;
end;

Regards,

-Anatoli

In article <39638e99@dnews>,
  "Pierre Greborio" <pie...@pierregreborio.it> wrote:

Quote
> > Do you have a link to where you saw that article?  The Save method
as
> defined in
> > the ADO 2.1 interface only takes a WideString filename parameter.
I think
> you
> > have to use a variant dispatch to get it to work.

> > try:

> >    Variant(rs).Save(xmlObj, adPersistXML);

> It doesn't works...type mismatch. I think that's an ADO 2.5 feature.

> The article ai found on MSDN library to
> mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%

20Studio\MSDN\2000APR\10

Quote
> 33. Looks with search to "recordset and DOM".

> Pierre

Sent via Deja.com http://www.deja.com/
Before you buy.

Other Threads