473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

WriteXml grouping data

I am using WriteXml to output data to an xml file, and and XML web
control to display it. The code runs fine, however my groups are
being ignored. For Instance, the current output is:

<NewDataSet>
<Table>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</Table>
<NewDataSet>

The "PRODUCT_CODE" is the group. I would like it to be:

<NewDataSet>
<Table>
<PRODUCT_GROUP>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<DETAIL>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</DETAIL>
</PRODUCT_GROUP>
</Table>
<NewDataSet>

My query is using a group by clause but the data always comes out the
same. Here is my code:

Dim SelectCommand As String = "SELECT top 100 PRODUCT_CODE,
PART_ID, PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE FROM RV_INVENTORY_VALUATION_MONTHEND " _
& "GROUP BY PRODUCT_CODE, PART_ID,
PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE"
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(SelectCommand,
myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

ds.WriteXml(server.mappath("../Administration/Month End
Inventory Valuation.xml"), XmlWriteMode.IgnoreSchema)

I appreciate any help.
Nov 18 '05 #1
2 1076
The name <Table> comes from the fact you did not use TableMappings on your
DataAdapter. It is a default name. If you use TableMappings, you can get
<PRODUCT_GROUP> as a table name tag.

To get child info under <DETAIL> you will have to create a DETAIL table
(TableMapping) and add a relationship.

If this is not possible, run the XML through XSLT to reorg as you wish.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Stephen Witter" wrote:
I am using WriteXml to output data to an xml file, and and XML web
control to display it. The code runs fine, however my groups are
being ignored. For Instance, the current output is:

<NewDataSet>
<Table>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</Table>
<NewDataSet>

The "PRODUCT_CODE" is the group. I would like it to be:

<NewDataSet>
<Table>
<PRODUCT_GROUP>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<DETAIL>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</DETAIL>
</PRODUCT_GROUP>
</Table>
<NewDataSet>

My query is using a group by clause but the data always comes out the
same. Here is my code:

Dim SelectCommand As String = "SELECT top 100 PRODUCT_CODE,
PART_ID, PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE FROM RV_INVENTORY_VALUATION_MONTHEND " _
& "GROUP BY PRODUCT_CODE, PART_ID,
PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE"
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(SelectCommand,
myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

ds.WriteXml(server.mappath("../Administration/Month End
Inventory Valuation.xml"), XmlWriteMode.IgnoreSchema)

I appreciate any help.

Nov 18 '05 #2
Thanks for the quick response Cowboy, however I think I used a bad
example. What I am actually looking for is structuring my data much
like a report, within a table using grouping:

-------------------------------------
Group1 <--merged cells
-------------------------------------
| price1 | description1 |
-------------------------------------
| price2 | description2 |
-------------------------------------
| price3 | description3 |
-------------------------------------
Group2 <--merged cells
-------------------------------------
| price1 | description1 |
-------------------------------------
| price2 | description2 |
-------------------------------------
| price3 | description3 |
-------------------------------------

I am placing the xml result in a table using xslt and want to merge
all columns in a row for the groups, while having the details in
cells, etc... I have looked at SQL Servers FOR XML EXPLICIT and union
queries, but it seems very cumbersome.

Thanks again.

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote in message news:<5A**********************************@microso ft.com>...
The name <Table> comes from the fact you did not use TableMappings on your
DataAdapter. It is a default name. If you use TableMappings, you can get
<PRODUCT_GROUP> as a table name tag.

To get child info under <DETAIL> you will have to create a DETAIL table
(TableMapping) and add a relationship.

If this is not possible, run the XML through XSLT to reorg as you wish.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Stephen Witter" wrote:
I am using WriteXml to output data to an xml file, and and XML web
control to display it. The code runs fine, however my groups are
being ignored. For Instance, the current output is:

<NewDataSet>
<Table>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</Table>
<NewDataSet>

The "PRODUCT_CODE" is the group. I would like it to be:

<NewDataSet>
<Table>
<PRODUCT_GROUP>
<PRODUCT_CODE>RM-Safety</PRODUCT_CODE>
<DETAIL>
<PART_ID>*61177-000</PART_ID>
<PART_DESCRIPTION>LABEL POUCH 1 PACK SOLO KR
AXIA</PART_DESCRIPTION>
<LABOR_COST>0</LABOR_COST>
<MATERIAL_COST>0.061000</MATERIAL_COST>
<BURDEN_COST>0</BURDEN_COST>
<SERVICE_COST>0</SERVICE_COST>
<TOTAL_VALUE>0</TOTAL_VALUE>
</DETAIL>
</PRODUCT_GROUP>
</Table>
<NewDataSet>

My query is using a group by clause but the data always comes out the
same. Here is my code:

Dim SelectCommand As String = "SELECT top 100 PRODUCT_CODE,
PART_ID, PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE FROM RV_INVENTORY_VALUATION_MONTHEND " _
& "GROUP BY PRODUCT_CODE, PART_ID,
PART_DESCRIPTION, LABOR_COST, MATERIAL_COST, " _
& "BURDEN_COST, SERVICE_COST,
TOTAL_VALUE"
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(SelectCommand,
myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds)

ds.WriteXml(server.mappath("../Administration/Month End
Inventory Valuation.xml"), XmlWriteMode.IgnoreSchema)

I appreciate any help.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the...
1
by: Rahul Agarwal | last post by:
Hi I am trying to write data back to the client using dataset.WriteXML and I have set the Thread.CurrentThread.CurrentCulture to "no" (norwegian) just before writing the data using WriteXML....
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
3
by: Gordon Moore | last post by:
Hi, I'm new to using xml/xslt and although I can create an xml document using the dataset.WriteXml statement, and I have created an xslt to transform the xml into the output I want, I have to...
1
by: Jacky | last post by:
hello i have to know if the writeXML process is a blocking process. Other mean if i write doc.WriteXML(); int i = 0; Is i = 0 can be executed before doc.WriteXML() method ended???? All this...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
2
by: Christina Androne | last post by:
Hello I am using the dataset.WriteXml method to convert a dataset's content to an XML string which will be parsed later on. I initally used WriteXml with a stream parameter, then got the string...
1
by: Luis Esteban Valencia | last post by:
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.