Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2005, 11:35 AM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
saving xml in asp.net using schema kavifs ASP.NET 1.0 and 1.1 Professional 0 February 23rd, 2007 10:32 AM
Save database schema to XML file brettk_1 General .NET 2 September 16th, 2006 04:27 AM
writing into xml file jerryjohn XML 1 August 18th, 2006 02:40 AM
writing to am xml file MOU Classic ASP XML 0 July 6th, 2005 07:38 AM
Writing XML file within Loop (c#) rathbird General .NET 0 December 13th, 2004 05:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.