473,487 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
Create 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 elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-micrsooft-com:mapping-schema">
<xs:element name="Visitors" nillable="true" type="VisitorList"
sql:is-constant="1" />
<xs:complexType name="VisitorList">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Visitor"
type="VisitorInfo" sql:relation="LiveMeetingAttendeesBMO1" />
</xs:sequence>
<xs:attribute name="Count" type="xs:int" use="required"
sql:mapped="false" />
</xs:complexType>
<xs:complexType name="VisitorInfo">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="ID"
type="xs:string" sql:mapped="false" />
<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="meetingName"
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="meetingTime"
type="xs:dateTime" sql:field="[Activity Day and Time]" />
<xs:element minOccurs="1" maxOccurs="1" name="startTime"
type="xs:dateTime" sql:field="Arrived" />
</xs:sequence>
</xs:complexType>
</xs:schema>

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

Heres my code to post to the database:

public void PostToDatabase(ConferenceType confType, MeetingInfo
Meeting)
{
SqlXmlCommand cmd = new SqlXmlCommand(Configuration.ConnectionString);
cmd.RootTag = "ROOT";
cmd.CommandType = SqlXmlCommandType.XPath;
cmd.CommandText = "LiveMeetingAttendeesBM01";
cmd.SchemaPath = "../../XML/VisitorList_Events.xsd";

DataSet dataset = new DataSet();
SqlXmlAdapter adapter = new SqlXmlAdapter(cmd);
adapter.Fill(dataset); //-- 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.Auto);
adapter.Update(dataset);
}

The "adapter.Fill(dataset)" 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 LiveMeetingAttendeesBMO1 table via the "sql:relation" 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 7521
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(Configuration.ConnectionString);
cmd.CommandText = "Visitor";
cmd.CommandType = SqlXmlCommandType.XPath;
cmd.SchemaPath = "../../XML/VisitorList_Events.xsd";

DataSet dataset = new DataSet();
SqlXmlAdapter adapter = new SqlXmlAdapter(cmd);

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

dataset.ReadXmlSchema(cmd.SchemaPath);
dataset.ReadXml(reader, XmlReadMode.ReadSchema);
dataset = dataset.GetChanges(DataRowState.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
1847
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...
8
8201
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...
0
1445
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...
4
2703
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...
3
2875
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
2239
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...
1
1337
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 ) + ) + ) > ^ ^ ^ ^ ^ ^ ...
0
2391
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...
0
2836
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...
4
4275
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...
0
7108
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,...
0
6967
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...
0
7142
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,...
0
7352
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...
1
4875
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...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
272
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...

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.