|
-
Nov 30th, 2010, 04:38 AM
#1
Thread Starter
Junior Member
How read XML schema with Primary Key?
Hello.
I import a XML to a Dataset and works fine, import XML with Schema and fine to, but for any estrange reason the primary key that is in the XSD don't appears in the Dataset.
The XML and XSD are generated from a access 2003 table, right button and export.
This is my code
Code:
str1 = "C:\tbl1.xml"
str2 = "C:\tbl1.xsd"
ds.ReadXml(str2, XmlReadMode.ReadSchema)
ds.ReadXml(str1)
Any help?
Thanks.
-
Nov 30th, 2010, 10:55 AM
#2
Hyperactive Member
Re: How read XML schema with Primary Key?
Can you provide the files tbl1.xml and tbl1.xsd? Whats Ds? Cna you provide the complete function code?
-
Nov 30th, 2010, 01:17 PM
#3
Re: How read XML schema with Primary Key?
ReadXml(fileName, mode) attempts to read an inline schema from an xml file. Have you tried using the ReadXmlSchema like:
Code:
Dim str1 = "C:\tbl1.xml"
Dim str2 = "C:\tbl1.xsd"
ds.ReadXmlSchema(str2)
ds.ReadXml(str1)
-
Dec 1st, 2010, 06:25 AM
#4
Thread Starter
Junior Member
Re: How read XML schema with Primary Key?
Good Morning.
ds is a dataset who is defined previously.
This is the xsd:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:od="urn:schemas-microsoft-com:officedata">
<xsd:element name="dataroot">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tbl1" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="generated" type="xsd:dateTime"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="tbl1">
<xsd:annotation>
<xsd:appinfo>
<od:index index-name="PrimaryKey" index-key="id " primary="yes" unique="yes" clustered="no"/>
<od:index index-name="id" index-key="id " primary="no" unique="no" clustered="no"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="id" minOccurs="1" od:jetType="autonumber" od:sqlSType="int" od:autoUnique="yes" od:nonNullable="yes" type="xsd:int"/>
<xsd:element name="name" minOccurs="0" od:jetType="text" od:sqlSType="nvarchar">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The function don't have more code.
For the sugerency about use reaXML without optional parameters, don't works 
I can add the primary key with code using:
Code:
DataColumn primarykey = ds.Tables["tbl1"].Columns["id"];
but is more right and clean if catch it from the XSD.
I continue searching in the web ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|