Can't use "FOR XML" query w/ _RecordsetPtr?
- From: "t-rex" <rexmtorres@xxxxxxxxx>
- Date: 27 Jun 2006 01:07:28 -0700
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.
.
- Follow-Ups:
- Re: Can't use "FOR XML" query w/ _RecordsetPtr?
- From: Stephen Howe
- Re: Can't use "FOR XML" query w/ _RecordsetPtr?
- Prev by Date: Re: Large varchar columns with SQL server
- Next by Date: Re: Large varchar columns with SQL server
- Previous by thread: Large varchar columns with SQL server
- Next by thread: Re: Can't use "FOR XML" query w/ _RecordsetPtr?
- Index(es):
Relevant Pages
|
|