Home > Archive > MS SQL XML > October 2005 > Problem with SQLXML when using annotations.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with SQLXML when using annotations.
vani

2005-10-27, 9:25 am

Hi,
I'm using SQLXML 3.0 in C# .NET.

I have an XML file "2.xml" and an associated XSD file "2.xsd".
When I validate the xml file against the schema. It validates properly. but
when I try to import the xml file into the db(SQL2000). it gives me an error

---------------------------
HRESULT="0x80004005" Description="Specified attribute or element ('Samples')
does not have a corresponding mapping in the schema, and no overflow field
defined"
----------------------------

I tried it with Tablename as the root element and the columns as the child
elements. It worked fine. but to have multiple records in the file I need to
have the choice tag and the Root element which is not mapped to any database
element in the database, it's posing problems. I tried the root tag with
sql:mapped="false" attribute also. Its showing the same error. Please let me
know what is going wrong and where!!!!!!!!!!!!!

Thanks in advance


------------------------------------------------------------------------------------------------
2.XSD
-------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xs:element name="Root" sql:is-constant="1">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Samples" sql:relation="SampleTable">
<xs:complexType>
<xs:sequence>

<xs:element name="Id" type="xs:integer" sql:field="Id" minOccurs="0"/>
<xs:element name="Name" type="xs:string" sql:field="Name" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>

</xs:element>

</xs:schema>
------------------------------------------------------------------------------------------------

2.xml
-------
<?xml version="1.0"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchem
aLocation="2.xsd">
<Samples>
<Id>1</Id>
<Name>a</Name>
</Samples>
<Samples>
<Id>2</Id>
<Name>b</Name>
</Samples>
</Root>

------------------------------------------------------------------------------------------------

Code
------
DataSet ds = new DataSet();

SqlXmlCommand cmd = new
SqlXmlCommand(" Provider=SQLOLEDB;Se
rver=(local);databas
e=Test;Integrated
Security=SSPI");

cmd.SchemaPath = @"C:\2.xsd";

//cmd.RootTag="ROOT";
//cmd.CommandText="SampleTable";
//cmd. CommandType=SqlXmlCo
mmandType.Sql;//.XPath;

SqlXmlAdapter adapter = new SqlXmlAdapter(cmd);
ds.ReadXml(@"C:\2.xml");

adapter.Update(ds);
-----------------------------------------------------------------------------------------------


Please reply to "deepak.gundappa@slk-soft.com"
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com