Read data from dataSet

F

Fox

I have create a dataSet and two table (father and son table) and set a
relationship between them (call father_uid (int)).

Is there any simple way, that I can get the row data include father and son
table items.
(do not use dataGuid)
eq

father_uid, father_field1,father_field2,son_field1,son_field2
1 "ABCD" 123.00 "XXXX" 456.00
1 "ABCD" 123.00 "YYYY" 567.00
2 "DEFG" 567.00 "aaaa" 456.00
2 "DEFG" 567.00 "bbbb" 567.00
2 "DEFG" 567.00 "cccc" 999.00

Thank for the help.
 
F

Fox

Thank you for your reply. It is work for normal dataSet, but don't work for
ds( read XML file). Finally thank you for you support. It is quite useful
for me.

Best Regards
Fox
 
C

Cor Ligthert

Fox,

Did you write that dataset before you read it with the overloaded method to
write the schema as well?

Cor
 
F

Fox

No, I just load the XML to the dataSet. But I have the schema w/o use it.
Thank you very much for your help.
 
F

Fox

The ture question. I have a XML and its schema.
I try to load the XML file into the dataSet and display on datagrid.
I find that It show pretty good on the datagrid.
So I want to retrive the data from dataSet to SQL server.
XML file something like
<Book_Rec>
<Books>
<Book>
<Name>Book Name</Name>
<Languages>
<Language>Chinese</Language>
<Language>English</Language>
</Languages>
<Prices>
<Price><Currency>HKD</Currency><Amount>100</Amount></Price>
<Price><Currency>USD</Currency><Amount>20</Amount></Price>
</Prices>
</Book>
<Book>
<Name>Book Name2</Name>
<Languages>
<Language>English</Language>
</Languages>
<Prices>
<Price><Currency>HKD</Currency><Amount>500</Amount></Price>
<Price><Currency>USD</Currency><Amount>70</Amount></Price>
</Prices>
</Book>
</Books>
I wounder how dataSet make good Relation between Book->Language,
and Book->Price.
How the dataSet so good relationship between them?
 
F

Fox

I just direct load the XML data file to the dataSet
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml("c:\\test.xml");
 
C

Cor Ligthert

Fox,

As far as I can see do you have in this dataset two tables, Books and
Languages which are saved nested

When you want to save them to SQL server you will have to have those tables
as well in that and update (in fact insert) them seperatly.

Normally first the books and than the languages.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top