Re: Please Help: SQLXML Bulk Load Error: Schema: relationship expected on 'Person'

From: Dennis Redfield (dennis.redfield_at_acadia-ins.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 08:52:43 -0500


try this:
Remove: sql:key-fields="id"

<this is used when your xml document contains data for multiple tables in a
Parent, child relationship>

Add:
dt:type="id"
to your existing:
<xs:attribute name="id" type="xs:string"/>

Add:

xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"

to your name space declarations within the

xs:schema

element

Try again.

hope this helps.

dlr

"Jay Murphy" <jwmurphy@iname.com> wrote in message
news:be2c9ecb.0403151816.4f76d1c9@posting.google.com...

> Hello,
>
> This is my first time playing with SQLXML and more specifically the
> bulk load features. I've created a very simple case. I'm trying to
> load data from an XML file into a single table called "Person".
> Here's an example of the XML file: The <ScriptObject> tag is
> generated through the XML export feature of an application I use.
>
> <?xml version="1.0" encoding="utf-8"?>
> <ScriptObject itemsName="items" id="0">
> <People>
> <Person id="1">
> <fname>Jane</fname>
> <lname>Smith</lname>
> </Person>
>
> <Person id="2">
> <fname>John</fname>
> <lname>Doe</lname>
> </Person>
>
> </People>
> </ScriptObject>
>
> I created the corresponding schema using "xsd.exe" and then annotated
> it by hand. The following is the annotated schema:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema id="NewDataSet" xmlns=""
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
> <xs:element name="ScriptObject">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="People" minOccurs="0" maxOccurs="unbounded"
> sql:is-constant="true">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="Person" minOccurs="0"
> maxOccurs="unbounded" sql:relation="Person" sql:key-fields="id">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="fname" type="xs:string"
> minOccurs="0" msdata:Ordinal="0" sql:field="fname"/>
> <xs:element name="lname" type="xs:string"
> minOccurs="0" msdata:Ordinal="1" sql:field="lname"/>
> </xs:sequence>
> <xs:attribute name="id" type="xs:string"
> sql:field="id"/>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> <xs:attribute name="itemsName" type="xs:string" />
> <xs:attribute name="id" type="xs:string" />
> </xs:complexType>
> </xs:element>
> <xs:element name="NewDataSet" msdata:IsDataSet="true"
> sql:is-constant="true">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element ref="ScriptObject" />
> </xs:choice>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> I realize that many of the "relation" and "field" mappings are
> generated by default however, I wanted to be explicit in order to
> illustrate the problem. I'm trying to load the data with the
> following C# program:
>
> using System;
>
> namespace bl
> {
> class Class1
> {
> [STAThread]
> static void Main(string[] args)
> {
> try
> {
> SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class objBL = new
> SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class();
> objBL.ConnectionString =
> "Provider=sqloledb;server=server;database=sample;integrated
> security=SSPI";
> objBL.ErrorLogFile = "error.xml";
> objBL.KeepIdentity = false;
> objBL.Execute ("schema.xsd","data.xml");
> }
> catch(Exception e)
> {
> Console.WriteLine(e.ToString());
> }
> }
> }
> }
>
> However, I encounter the following error:
>
> Schema: relationship expected on 'Person'
>
> I've read the documentation for sql:relationship and I'm scratching my
> head because in my situation there's only the single table "Person".
> No parent, child or foreign key relationships.
>
> I must be overlooking something simple. What am I doing wrong?
>
> Thanks so much,
> Jay Murphy



Relevant Pages

  • Re: GedCom standards
    ... and logic used to establish a parent child relationship. ... Can anyone confirm that this is in fact a limitation in the GedCom ... as most other genealogy programs require. ...
    (soc.genealogy.methods)
  • Re: GedCom standards
    ... and logic used to establish a parent child relationship. ... there is an "ADOP" event available for each individual. ... and a sub-tag to specify which or both parents ...
    (soc.genealogy.methods)
  • Re: Problem with AppendChild
    ... The limitations are not so short as that, does your XML document have a DTD that says otherwise? ... It's not clear if CLIENT-SERVER-INTERFACE is the "parent" you speak of or is the node you are adding to something unmentioned. ... public class DomExample { ... DocumentBuilder builder = null; ...
    (comp.lang.java.help)
  • Re: Using XPath Against A Node
    ... top parent? ... Or is the entire xml document sent with it. ... In terms of the XPath implementation with SelectSingleNode and SelectNodes if the node is not inserted in the owning document then it looks like the XPath / evaluates to the node itself. ...
    (microsoft.public.dotnet.languages.vb)
  • Problem Joining Parent and Children
    ... I'm having problems joining the parent and children together from an ... parent rows. ... The XML Document is a little different than what I like to work with, ... exec sp_xml_preparedocument @hdoc output, @doc ...
    (microsoft.public.sqlserver.xml)

Quantcast