xml - dataset question

joeybagadonutz

Well-known member
Joined
Nov 6, 2003
Messages
72
Hi.

My goal here is to import an xml file into my sql server database. (Im semi new to using xml)

First, I am importing the xml file into a dataset using ReadXml. When I first did this, I would bind a datagrid to the dataset, and it worked great, but it was in a hierchechal style view....with plus symbols etc that would expand the records into more detailed information. This isnt really what I wanted, I just want to import all the info into a single table....but, I discovered that the dataset actually consists of 14 different tables after I import the xml file.

Theoretically, this would be fine, I can just create 14 tables in my database...(or create my own table with what i want in code) but what Im mega confused about is that some of the tables have no relational field whatsoever to the other tables. So I do not understand how the data tables in my dataset relate to each other. (i created 14 datagrids on a form and populated them all with thier respective table from the dataset, and there is no field displayed to relate them). I assume this is because the dataset was created from xml and somehow it knows how they are related...but I dont know how to access that information.

Anyway, how do I relate these 14 tables in my dataset together so I can populate tables in my database and be able to use them? (I thought of adding a field to each table in code and relate them that way, but that wont work as I wont be able to relate it in my code either :)) What am I missing here? thanks much, I do appreciate any assistance.

-JBD
 
joeybagadonutz said:
Theoretically, this would be fine, I can just create 14 tables in my database...(or create my own table with what i want in code) but what Im mega confused about is that some of the tables have no relational field whatsoever to the other tables. So I do not understand how the data tables in my dataset relate to each other. (i created 14 datagrids on a form and populated them all with thier respective table from the dataset, and there is no field displayed to relate them). I assume this is because the dataset was created from xml and somehow it knows how they are related...but I dont know how to access that information.

Ok, so I cant really answer your questions, but I know DataSets have a Relations property which is a DataRelationCollection class that "contains a collection of DataRelation objects; otherwise a null value if no DataRelation objects exist." Perhaps you could investigate this further to see if any relations were automatically generated?

DataSet Relations Property (.NET Framework)
 
fizzled said:
Ok, so I cant really answer your questions, but I know DataSets have a Relations property which is a DataRelationCollection class that "contains a collection of DataRelation objects; otherwise a null value if no DataRelation objects exist." Perhaps you could investigate this further to see if any relations were automatically generated?

DataSet Relations Property (.NET Framework)
Hi thanks. I figured it out. basically I wrote the xml schema into a multiline text box using writexmlschema in the dataset. I then copied and pasted that schema into the xml designer of visual studio, and it gave me the layout of all the tables in the dataset. I found that the columns that related them were hidden...so, anyway, I created tables that matched in my database and I update the data tables right from the dataset. It works great, thanks :)
 
Back
Top