Hi,
I do use SQLOLEDB provider V 2.82 to connect to MSSQL Server 2005. I try to
get row data in XML form. The code is the following
CCommand<CXMLAccessor> cXMLCmd;
CStringW so,sot;
cXMLCmd.Create(session, "select * from tmp for XML RAW('item'),
root('records')") ;
cXMLCmd.Open();
cXMLCmd.MoveFirst();
cXMLCmd.GetXMLColumnInfo( so );
cXMLCmd.GetXMLRowData( sot );
As a result the variables have the following:
so {0x0017d270 "<columninfo><column
type="STRING">XML_F52E2B61-18A1-11d1-B105-00805F49916B</column></columninfo >
"}
sot {0x0017cc60
"<row><XML_F52E2B61-18A1-11d1-B105-00805F49916B>440B640069006D00670072006F0 0
750070005F0069006400440D640069006D00670072006F00750070005F006E0061006D00650 0
44046900740065006D000100077200650063006F00720064007300410103020142060000000 2
0210E30400000500557365727343010302014207000000020210E30400000800436F6D6D616 E
647343010302014208000000020210E3040000070047726F75705F4E4301030201420900000 0
020210E3040000050046696C6573438100077200650063006F00720064007300</XML_F52E2 B
61-18A1-11d1-B105-00805F49916B></row>"}
But I'd like that 'sot' would be in the form as below:
<records><item dimgroup_id="6" dimgroup_name="Users"/><item dimgroup_id="7"
dimgroup_name="Commands"/><item dimgroup_id="8"
dimgroup_name="Group_N"/><item dimgroup_id="9"
dimgroup_name="Files"/></records>
How is it to reach that?
Thanks.
--
Andrei.
Hi
CREATE TABLE [dbo].[OrderDetails](
[OrderDetailID] [int] IDENTITY(1,1) NOT NULL,
[OrderNumber] VARCHAR(10) NOT NULL,
[ItemNumber] [varchar](20) NULL,
[Qty] [int] NULL,
[Rate] FLOAT NULL
) ON [PRIMARY]
INSERT INTO OrderDetails (OrderNumber, ItemNumber, Qty, Rate)
SELECT 'Order1', 'Item1', 20, 115.25
UNION SELECT 'Order2', 'Item2', 47, 45
UNION SELECT 'Order3', 'Item3', 89, 74.12
SELECT
OrderNumber,
ItemNumber,
Qty
FROM OrderDetails FOR XML RAW('itemInfo'), TYPE, ELEMENTS, ROOT('orderInfo')
"Andrei Zakharov" <z
@newsgroup.nospam> wrote in message
news:%23iicSGAqHHA.3892@TK2MSFTNGP05.phx.gbl...
> Hi,
> I do use SQLOLEDB provider V 2.82 to connect to MSSQL Server 2005. I try
> to
> get row data in XML form. The code is the following
> CCommand<CXMLAccessor> cXMLCmd;
> CStringW so,sot;
> cXMLCmd.Create(session, "select * from tmp for XML RAW('item'),
> root('records')") ;
> cXMLCmd.Open();
> cXMLCmd.MoveFirst();
> cXMLCmd.GetXMLColumnInfo( so );
> cXMLCmd.GetXMLRowData( sot );
> As a result the variables have the following:
> so {0x0017d270 "<columninfo><column
> type="STRING">XML_F52E2B61-18A1-11d1-B105-00805F49916B</column></columninfo >
> "}
> sot {0x0017cc60
> "<row><XML_F52E2B61-18A1-11d1-B105-00805F49916B>440B640069006D00670072006F0 0
> 750070005F0069006400440D640069006D00670072006F00750070005F006E0061006D00650 0
> 44046900740065006D000100077200650063006F00720064007300410103020142060000000 2
> 0210E30400000500557365727343010302014207000000020210E30400000800436F6D6D616 E
> 647343010302014208000000020210E3040000070047726F75705F4E4301030201420900000 0
> 020210E3040000050046696C6573438100077200650063006F00720064007300</XML_F52E2 B
> 61-18A1-11d1-B105-00805F49916B></row>"}
> But I'd like that 'sot' would be in the form as below:
> <records><item dimgroup_id="6" dimgroup_name="Users"/><item
> dimgroup_id="7"
> dimgroup_name="Commands"/><item dimgroup_id="8"
> dimgroup_name="Group_N"/><item dimgroup_id="9"
> dimgroup_name="Files"/></records>
> How is it to reach that?
> Thanks.
> --
> Andrei.