473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

populate dataset fk value using xmlschema xsd

I am trying to use xml shema to load xml file to a dataset. Here are
two tables:

Table Item:
Item_ID (key)
Name
Category_ID (foreign key from table Category)

Table Category:
Category_ID (key)
Description

I set relationship between 2 tables as commented above

Here is a part of my xml file:

<Category DisplayName="Cat 1">
<Item Name="Item 1" />
<Item Name="Item 2" />
<Item Name="Item 3" />
</Category>
<Category DisplayName="Cat 2">
<Item Name="Item 4" />
<Item Name="Item 5" />
<Item Name="Item 6" />
</Category>

Here are some codes:

// MySchema (or MySchema.xsd) is a schema defining two tabels in
above
// using VS dataset designer in the porject
private MySchema m_Shema = new MySchema;

string sFile = @"C:\temp\myItems.xml";
this.m_Shema.ReadXml(sFile);

The problem is that table Item does not have any values for
Category_ID column. They are empty! Based on the relationship, it
should be key values in Category table (Category table is fine). How
can I set the schema so that ReadXML() will read the relationship
values correctly in tabe Item?

Mar 14 '07 #1
1 2215
After calling ReadXML(), the Table Category is:

Category_ID Description
0 Cat 1
1 Cat 2

and the table Item:

Item_ID Name Category_ID
0 Item 1
1 Item 2
2 Item 3
3 Item 4
4 Item 5
5 Item 6

What I expected for table Item should be:

Item_ID Name Category_ID
0 Item 1 Cat 1
1 Item 2 Cat 1
2 Item 3 Cat 1
3 Item 4 Cat 2
4 Item 5 Cat 2
5 Item 6 Cat 2

The relationship is defined between Item and Category tables, but the
result of Category_ID in table Item is empty.

Mar 14 '07 #2

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

Similar topics

1
by: harry | last post by:
Hello, not certain if this should go here or ado.net but I'm trying to create an XSD on the fly (due to the fact that our dataaccess component is a legacy component which returns data in an...
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
8
by: drg | last post by:
I have a DataSet with a DateTime field. I am using an EventRow r, to update it with values from a TextBox in a DataGrid. Suppose a DataGrid in edit mode had a field with value: 7/7/2005. Then the...
4
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the...
2
by: MarkAurit | last post by:
How does one go about getting the information from an .xsd file into a WSDL document? I have a web service that creates a simple object that IBM Websphere can see and use. Great. However, when I...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.