Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.