ADO.NET PROBLEM writing XML file by schema using datasets

A

Andrius

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.
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,

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

And, your question regarding the use of the C language was??

- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFB/8O6agVFX4UWr64RAluCAKCgxFgktHpvJT8PL9F9TseB8tY7HwCfbXUx
MyU/5PHCobqdpizFq9LqBO0=
=Ds5u
-----END PGP SIGNATURE-----
 
M

Martin Ambuhl

Andrius said:
Hello,

having some problems by writing XML file by XML schema.
using strongly typed datasets.
[followed by much more non-C content]

How did you choose comp.lang.c to post to? Do you have a
random-newsgroup generator?
 
J

Jonathan Burd

Andrius said:

Sorry, I am new with XML.

thanks for help.

XML, SQL, and C# have nothing to do with this newsgroup.
Please find a newsgroup that suits your purpose
and post in there. This group is about the
C language.

[Followups set to alt.pl.comp.lang.csharp]

Regards,
Jonathan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top