Filling Dataset With a predefined XSD

P

Praveen

Hello All,
I wanted to query database and make an XML using WriteXML function in the
dataset. When I use WriteXML function the XML structure is according to some
default schema. I wanted the schema to be defined by me (given below).
I tried using ReadSchema function before calling the fill function in the
dataAdapter but that did not help

can someone please advice
Thanks in advance,
Praveen



<?xml version="1.0" standalone="yes"?>
<xs:schema id="ROOT" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="ROOT" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="I">
<xs:complexType>
<xs:sequence>
</xs:sequence>
<xs:attribute name="NTID" type="xs:string" />
<xs:attribute name="U" type="xs:string" />
<xs:attribute name="T" type="xs:string" />
<xs:attribute name="PJNAM" type="xs:string" />
<xs:attribute name="SNDR" type="xs:string" />
<xs:attribute name="SDT" type="xs:string" />
<xs:attribute name="C" type="xs:string" />
<xs:attribute name="P" type="xs:string" />
<xs:attribute name="S" type="xs:string" />
<xs:attribute name="E" type="xs:string" />
<xs:attribute name="SID" type="xs:string" />
<xs:attribute name="ITMID" type="xs:string" />
<xs:attribute name="ITYP" type="xs:string" />
<xs:attribute name="PRTY" type="xs:string" />
<xs:attribute name="EDT" type="xs:string" />
<xs:attribute name="TYP" type="xs:string" />
<xs:attribute name="RUNR" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="ROOTKey1" msdata:primaryKey="true">
<xs:selector xpath=".//I" />
<xs:field xpath="@NTID" />
</xs:key>
</xs:element>
</xs:schema>
 
K

Kevin Yu [MSFT]

Hi Praveen,

Thanks for pasting the schema here. This schema is a valid DataSet schema
and we can write the xml with the desired schema. But we have to make sure
whether the data has been filled to the 'I' Table. Please try to use
XmlWriteMode.WriteSchema to output the data and schema together. You can
check if the data is in the desired table. If you have any problem, please
post the xml here. Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
P

Praveen

Hello Kevin

I was able to get the desired result. there are 2 ways of doing this. One as
you mentioned.
and second is by making use of TableMapping like below.

dbAdptr.TableMappings.Add("Table","I")

The second approach is better because if we are calling a procedure
returning multiple cursors we can handle this situation by setting the table
mapping for each dataTable.

Regards,
Praveen
 
K

Kevin Yu [MSFT]

Hi Praveen,

It was nice to hear that you have had the problem resolved. Thanks for
sharing your experience with all the people here. If you have any
questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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

Top