473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlXmlException - Schema: relationship expected on <element name>. Help!

Ok, brand new to SQLXML 3.0 and its various issues. Heres what I'm
trying to do:

1. I am trying to load xml data into an empty SQL table from my .NET
console application.
2. This isn't a huge amount of data so I'm not interested in
BulkXMLLoad (or whatever its called).
3. I have the xml and xml schema ready to go, with (I hope) the proper
sql annotations.

Heres my xml schema (built via xsd tool with added sql annotations):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefa ult="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn: schemas-micrsooft-com:mapping-schema">
<xs:element name="Visitors" nillable="true" type="VisitorLi st"
sql:is-constant="1" />
<xs:complexTy pe name="VisitorLi st">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbo unded" name="Visitor"
type="VisitorIn fo" sql:relation="L iveMeetingAtten deesBMO1" />
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"
sql:mapped="fal se" />
</xs:complexType>
<xs:complexTy pe name="VisitorIn fo">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="ID"
type="xs:string " sql:mapped="fal se" />
<xs:element minOccurs="0" maxOccurs="1" name="userName"
type="xs:string " sql:field="Name " />
<xs:element minOccurs="0" maxOccurs="1" name="Role"
type="xs:string " />
<xs:element minOccurs="0" maxOccurs="1" name="email"
type="xs:string " />
<xs:element minOccurs="0" maxOccurs="1" name="company"
type="xs:string " />
<xs:element minOccurs="0" maxOccurs="1" name="ipAddress "
type="xs:string " sql:field="[IP Address]" />
<xs:element minOccurs="0" maxOccurs="1" name="browser"
type="xs:string " />
<xs:element minOccurs="0" maxOccurs="1" name="meetingNa me"
type="xs:string " sql:field="[Meeting ID]" />
<xs:element minOccurs="1" maxOccurs="1" name="duration"
type="xs:int" />
<xs:element minOccurs="1" maxOccurs="1" name="meetingTi me"
type="xs:dateTi me" sql:field="[Activity Day and Time]" />
<xs:element minOccurs="1" maxOccurs="1" name="startTime "
type="xs:dateTi me" sql:field="Arri ved" />
</xs:sequence>
</xs:complexType>
</xs:schema>

As you can see, one Visitor record should apply to one record in the
backend SQL table, named LiveMeetingAtte ndeesBMO1.

Heres my code to post to the database:

public void PostToDatabase( ConferenceType confType, MeetingInfo
Meeting)
{
SqlXmlCommand cmd = new SqlXmlCommand(C onfiguration.Co nnectionString) ;
cmd.RootTag = "ROOT";
cmd.CommandType = SqlXmlCommandTy pe.XPath;
cmd.CommandText = "LiveMeetingAtt endeesBM01";
cmd.SchemaPath = "../../XML/VisitorList_Eve nts.xsd";

DataSet dataset = new DataSet();
SqlXmlAdapter adapter = new SqlXmlAdapter(c md);
adapter.Fill(da taset); //-- ERROR HITS HERE

//this serializes class into XML according to schema above.
XmlTextReader reader = ConvertToXML();

//now load dataset with new records and update database!
dataset.ReadXml (reader, XmlReadMode.Aut o);
adapter.Update( dataset);
}

The "adapter.Fill(d ataset)" line causes the error - SqlXmlException :
Schema: relationship expected on 'Visitor'.

I'm not sure why this is appearing... there is no join here, so I don't
need a relationship right? I also map my Visitor elements to records in
the LiveMeetingAtte ndeesBMO1 table via the "sql:relati on" attribute.

Has anyone seen anything like this?

NOTE: The sql:is-constant='1' attribute in the schema - the results are
the same with or without it.

Thanks for the help!! :)

J'son

Nov 12 '05 #1
2 7532
Some clarity after banging my head on my desk:

I think that since my initial table in the SQL database is empty, the
fill code is unnecessary. Also, in reading some more I figured out that
the CommandText refers to the XSD file of the SqlXmlCommand when using
CommandType = XPath (duh!). So here is the updated PostToDatabase( )
function:

public void PostToDatabase( ConferenceType confType, MeetingInfo
Meeting)
{
SqlXmlCommand cmd = new
SqlXmlCommand(C onfiguration.Co nnectionString) ;
cmd.CommandText = "Visitor";
cmd.CommandType = SqlXmlCommandTy pe.XPath;
cmd.SchemaPath = "../../XML/VisitorList_Eve nts.xsd";

DataSet dataset = new DataSet();
SqlXmlAdapter adapter = new SqlXmlAdapter(c md);

//this serializes class into XML according to schema above.
XmlTextReader reader = ConvertToXML();

dataset.ReadXml Schema(cmd.Sche maPath);
dataset.ReadXml (reader, XmlReadMode.Rea dSchema);
dataset = dataset.GetChan ges(DataRowStat e.Added);

adapter.Update( dataset); //-- ERROR NOW HAPPENS
HERE (SAME ERROR)
}

Same error occurs, just now on the adapter.Update method so its still
an issue with my schema.

Thanx!

Sincerely,

J'son

Nov 12 '05 #2
Figured it out... check out my urn for the xmlns:sql namespace in the
schema - micrsooft! Arrrggh... :P

J'son

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1856
by: Christopher | last post by:
I came across this line in a lib I am studing, it simply has class cSceneNode; all by itself. what is that line doing? I am used to seeing a declaration: MyClass test; or definition: class MyClass{ public: foo();}; but never just: class <name>; Thanx, Christopher
8
8208
by: SteveK | last post by:
I'm getting the error: "Cannot implicitly convert type 'MovesDBMigrate.MotionNameElementTypes' to 'int'" for this line of code: m_nameElementTableNames = "Tbl_NameCharacters"; Of course if I cast int to it, then it compiles, but if I have declared the enum's type as int, why do I need to cast int to the value?
0
1449
by: Doug | last post by:
I got this as soon as I installed Vis Studio 2003, which either requires different permissions to inetpub\wwwroot or changed them during installation. I couldn't open an existing solution or create a new one. Very frustrating. The solution (for me, anyway) was to change the permissions to the inetpub\wwwroot folder. I needed these...
4
2705
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the source of the files...
3
2878
by: noreponse1 | last post by:
Hello, I have a solution that contains two projects. I have 2 dlls that these projects use. Here's how it's set up: Solution -ProjectA --References ---DLLA -ProjectB
1
2242
by: MAILTONRK | last post by:
Hi, I am a Mainframe guy. I am working with MS access(maintaining a application) for the last 2 weeks. I had one master database and four replicas. One of my replica had trouble in synchronization(It said, database is in use..). After searching google, I ran "Compact and repair" utlity against my replica. It looks like, it has changed...
1
1345
by: mahesh.kanakaraj | last post by:
Hi folks, I just have a doubt on whether the below DTD declaration for an element is valid or not. <!ELEMENT e_name ( ( stu * | ( vw , x ) + ) + ) > ^ ^ ^ ^ ^ ^ ^ ^ ^ 1 2 3 4 5 6 7 8 9
0
2405
by: sphinney | last post by:
I have a complex Access 2002 database with multimple tables, queries, forms, and reports. The database is used by miltiple users that have one of four different levels of security. The databae uses a workgroup security file. The database is designed to be opened without the workgroup security file by general users (who have the lowest...
0
2848
by: Andrzej Lipski | last post by:
Hello I am developing a Windows Ce 5.0 mobile application. I followed the example shown at : Creating Self-Updating Applications With the .NET Compact Framework http://msdn2.microsoft.com/en-us/library/aa446487.aspx I was able to build the Cab file installer and Setup for the application just fine and I created the CustomInstaller in VB...
4
4284
by: smadadi | last post by:
When iam trying to save changes to some of the reports i am getting the error message as 'Couldn't save currently locked by user admin on machine <name>' happening with only some of the reports not with all. Can any one help me?
0
7542
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7467
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7736
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7982
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7827
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5385
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1079
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.