Datasets and XML/XSD

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am using XML to store my datasets.
I am using 2 files: "MyXMlFilename.xml" to store the data values (all the rows) and "MyXMlFilename.xsd" to store the schema. I use DataSet.ReadXml(Full path of MyXMlFilename.xml) to read the data and DataSet.ReadXmlSchema(full path of MyXMlFilename.xsd) to read the schema. The schema definition contains Column1 as primary key. Therefore it is expected that when i add a new row into the dataset (using DataSet.Tables[0].AddRow()) with a same Column1 value, it should throw me some exception, but unluckily it is not. Instead it is adding the row with the same value and hence duplication of Column1 values. Where exactly is going wrong?

The amusing thing is if I have a single file(MyXMLFileName.Xml) which have both Schema as well as data then it certainly give me an exception, but if I have two different files as I explained above, it doesnt throw exception..

Is there any reference site where i can get around this problem, or some samples for ready reference..

Please help..
thanks a lot

Amit.
 
Amit,

There's no difference if schema is loaded from XSD file or from data file.
DataSet.ReadXmlSchema() will be called internally anyway, doing exactly the
same thing.

Make sure your schema is correct and loaded without exceptions.
Check if constraints are enabled.
Also make sure schema is loaded before data.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: Datasets and XML/XSD
thread-index: AcQsVOaQ7T89p5c5R9S0UQH9dNizLw==
X-WN-Post: microsoft.public.dotnet.framework.compactframework
From: "=?Utf-8?B?QW1pdCBQYXRhbmthcg==?="
Subject: Datasets and XML/XSD
Date: Tue, 27 Apr 2004 05:41:03 -0700
Lines: 12
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
Path: cpmsftngxa10.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:51828
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hi,
I am using XML to store my datasets.
I am using 2 files: "MyXMlFilename.xml" to store the data values (all the
rows) and "MyXMlFilename.xsd" to store the schema. I use
DataSet.ReadXml(Full path of MyXMlFilename.xml) to read the data and
DataSet.ReadXmlSchema(full path of MyXMlFilename.xsd) to read the schema.
The schema definition contains Column1 as primary key. Therefore it is
expected that when i add a new row into the dataset (using
DataSet.Tables[0].AddRow()) with a same Column1 value, it should throw me
some exception, but unluckily it is not. Instead it is adding the row with
the same value and hence duplication of Column1 values. Where exactly is
going wrong?

The amusing thing is if I have a single file(MyXMLFileName.Xml) which have
both Schema as well as data then it certainly give me an exception, but if
I have two different files as I explained above, it doesnt throw
exception...

Is there any reference site where i can get around this problem, or some
samples for ready reference...

Please help...
thanks a lot.

Amit.
 
Thanks a lot Ilya..
Actually I was reading XML file before reading the Schema and that was creating the problem

Thanks a ton
Amit.
 
Back
Top