Anyone know anything about Datasets (MSDataSetGenerator-generated ones)?

Man of Honour
Joined
18 Oct 2002
Posts
13,262
Location
Northallerton/Harrogate
I'm having a bit of a mare with this.

Some of you may remember me whining on about reading in an xml file, which I sorted by Serializing it. Hooray.

Anyway, here's what I had:
An xml file
The xsd file for said xml file.

I used xsd.exe to generate classes from the xsd file, all good. But this had to (?) be done from the command line and if ever the layout or whatever of the xml changed, for example - if I later decide to add in some extra elements then I'd hate to regenerate the classes using xsd.exe, right?

That's not terrible, but is there a way to automate all that from within VS.net 2008?

I was told to check out MSDataSetGenerator as a custom tool, which is run against the .xsd file. It generates this huge wall of text (that crits you for 34,736) DataSet:
Code:
private serverconfigDataTable tableserverconfig;
        
private recipientDataTable tablerecipient;
        
private triggersDataTable tabletriggers;
        
private global::System.Data.DataRelation relationrecipient_triggers;
        
private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema;

etc. etc. - However I haven't a clue what to do with it or how to use it.

The classes version as generated by xsd is much simpler and easier to understand, and just has properties for get/set each of the elements....piece o' cake to use. Even I understand it.

So essentially, what I'm doing at the moment is reading in this xml file that contains server config and e-mail recipients details, then accessing them via the generated class(es) like so:

Code:
// Read in the XML file that contains list of e-mail recipients and associated triggers
TextReader reader = new StreamReader(ConfigurationFilename);
XmlSerializer serializer = new XmlSerializer(typeof(emailnotification));
emailnotification en = (emailnotification)serializer.Deserialize(reader);

// Get server connection details from xml config file
emailnotificationServerConfig sc = en.serverconfig
            
string server = sc.server;
string username = sc.username;
string password = sc.password;

And all is well. I can't post up any complete code, but I'd like to use the same .xml file with the dataset solution - if that's even possible. Like I said, I really don't understand datasets - well I would if it were connecting to a database, but it's not; it's just a flat xml file.

Does anyone have the slightest idea what i'm on about?
 
Understand what you've got, understand about the datasets, but haven't a clue what you're asking? :)
 
Understand what you've got, understand about the datasets, but haven't a clue what you're asking? :)

Well, I think I've generated a dataset from the .xsd file.

How do I use it, load in the data from xml file and get at it like I could via the classes, is (i think) what I'm asking.
 
From what I understand, and I'm not pretending to be 'the' expert here, just what I personally use...

The XSD is the actual definitions of the data fields themselves. It's like the XSD file is the "SQL Table" yet each element is the "SQL Field" and each attribute is the "SQL Field properties"

But you'd create a blank dataset, read in the XSD to define the actual dataset itself (name, fields, field properties) and then read in the XML to populate the dataset.

So you've not exactly created a dataset as such with the XSD file, but you have created the fundamental building blocks on what a newly created Dataset should be before it starts to hold data.

Like I said, that's my understanding and how I do things.
 
Back
Top Bottom