473,378 Members | 1,333 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,378 software developers and data experts.

ADO.NET writing XML file by schema using datasets

Hello,

having some problems by writing XML file by XML schema.
using strongly typed datasets.

Schema:

<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="types.xsd" />
<xs:element name="CharactList">
<xs:complexType>
<xs:sequence>
<xs:elementname="Charact"maxOccurs="unbounded">
<xs:complexType> <xs:sequence>
<xs:element name="Id" type="Id" /> <xs:element
name="Did" type="Id" />
<xs:element name="Operation" type="Operation" />
<xs:element name="DateFrom" type="ISODate" />
<xs:element name="Characteristics">
<xs:complexType>
<xs:sequence>
<xs:element name="RiskGroup" type="RiskGroup" minOccurs="0" />
<xs:element name="Interest" type="Interest" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

C# code:

// xml schema compiled to dll
CharactList charactDS = new CharactList();
SqlDataAdapter charactCMD = new SqlDataAdapter(q1, lizingConn);

int i = charactCMD.Fill(charactDS, "Charact");
richTextBox1.Text+= "Rows:" + i;

charactDS.WriteXml("Charact.xml", XmlWriteMode.WriteSchema);
....

Everything is working, but generated new XML file isn't what i need:

<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
</Charact>

It must be like this:

<Charact>
<Id>4648</Id>
<Did>14252</Did>
<Operation>COR</Operation>
<DateFrom>2004-12-31</DateFrom>
<Characteristics>
<Interest>4.265</Interest>
</Characteristics>
</Charact>

SQL statement is good, it returns Interest and RiskGroup values, how
to put those values to XML?

SQL:

SELECT
SutCSutId AS Id,
SutCIstId AS Did,
SutCOper AS Operation,
Convert(Char(10),SutCDate,126) AS DateFrom
Convert(Decimal(18,3),SutCVerte*100) AS Interest,
SutCRizika AS RiskGroup
FROM
SutCharacter AS chr
INNER JOIN Sutartys AS sut
ON chr.SutCSutId = sut.SutId
WHERE
SutCOper <> 'DEF' AND
SutTipas <> 'SV' AND
SutBusena IS NULL AND
SutCIstId IS NOT NULL
;

Sorry, I am new with XML.

thanks for help.
Nov 12 '05 #1
0 1333

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

Similar topics

6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
0
by: Andrew Dawson | last post by:
I am looking into the possibilities that exist from utilizing XML Schema documents to store the structure of datasets that don't change frequently for access in distributed applications. I...
0
by: Lindy | last post by:
I have a schema file called asc.xsd which I have added to my project .Net project (VB). I am using XMLTextWriter in order to create/write data to a new XML file. Is there a way to access the...
1
by: davis | last post by:
Hello, I am working in .Net C# and have an xml file similar to the one below. I have tried using a DataSet but get the error "The same table (Gid) cannot be the child table in two nested...
13
by: Jerry C | last post by:
I am using some sample code from gotdotnet to Create DataSet mappings from a xsd schema. I am geting this error. code and error below. I might mention there is also a publictypelibrary file with...
13
by: Martin Z | last post by:
I'm making a CRUD screen for an Oracle database... but problem is that the primary key in that table is populated via an autonumber, which in Oracle is done just with triggers and sequences. ...
13
by: Bill Nguyen | last post by:
Is it possible to create your won XSD to use with .NET based on an XML content? For example the one below: <?xml version="1.0"?> <pcats:FuelsDoc...
0
by: ErikaW | last post by:
Hi all, I've tried to google this but could not find a clear solution. I have a Web application developed in JDevloper using mostly html and Javascript. I have a pre-defined PDF form which I merge...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.