Can't use "FOR XML" query w/ _RecordsetPtr?



Hi,

I've already posted this somewhere else, but, I'm posting it again here
because someone suggested that this is the more appropriate discussion
group on which to post my problem... (OK... that was a long intro.. :p)

Anywayz, I'm a newbie (very new) in ADO programming and I'd like to
know if you can use MSSQL's "FOR XML" query with _RecordsetPtr. I've
already tried something like:

_ConnectionPtr connection;
_RecordsetPtr recordset;
_bstr_t query = "SELECT p.FirstName, p.LastName, c.MobileNum,
c.HomeNum ";
query += "FROM PersonInfo p, ContactInfo c WHERE p.PersonID =
c.PersonID ";
query += "FOR XML AUTO, ELEMENTS";

...

recordset->Open(query, connection.GetInterfacePtr(),
adOpenStatic, adLockBatchOptimistic, adCmdUnknown);
recordset->Save("C:\\testrs.xml", adPersistXML);

What I'm trying to do here is save the result of the query to a file in
XML format. However, I have to be able to generate the XML in such a
way that the format is the same as with when you execute the query
using _CommandPtr (with its output stream set to a _StreamPtr object).
With the above procedure, however, I get an XML file w/ unreadable data
(???). But, if I do remove the "FOR XML AUTO, ELEMENTS" clause, I get
all the correct data from the query but with the XML structured in a
different way (as compared w/ _CommandPtr's result). The reason why
I'm concerned w/ the structure is because the user of the XML file is
dependent on the structure.

Does not _RecordsetPtr support the "FOR XML" clause? Or does it, but,
I'm using _RecordsetPtr incorrectly? Can anyone help me with this?

Thanks in advance.

.



Relevant Pages

  • Re: password never expires
    ... It is an xml file, but you can just as easily make your own by adding a ... If you'd still like it emailed post back and I'll send it along ... Is this supposed to be a query definition in xml?? ...
    (microsoft.public.windows.server.active_directory)
  • How to import a XSD and XML file into a SQL table
    ... I have generated the output of a SQL query against Northwind in the ... form of the XSD and the XML file for a query using the following query: ... For generating the XML output: ... I use the following query to generate a XSD output of the ...
    (microsoft.public.sqlserver.xml)
  • Re: Querying XML Files
    ... Ken if i would like to Query and xml file like (Will it be possible to use ... <TREENODES> ... This is the XML structure a Treeview Webcontrol Menu uses and i have wanted ...
    (microsoft.public.dotnet.framework.aspnet)
  • Query an XML file like a recordset?
    ... With ASP can I query an XML file for a record, ... database table and fill the data values into variables? ...
    (microsoft.public.inetserver.asp.db)
  • Re: xml in plain text file on heavy load.
    ... even if the XML file is magically and perfectly ... I want to emphasize that IIS would never be caching that XML file on its own ... Application is NOT synchronizing access to your ASP pages. ...
    (microsoft.public.inetserver.iis)