I use a DataGrid to show a xml file. The Grid’s DataSource is a Typed DataSet.(using schema)
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream("XML_Reader.Resources.schema.xsd");
XmlSchemaSet schemas = new XmlSchemaSet();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null, XmlReader.Create(stream));
using (XmlReader reader = XmlReader.Create(xmlFile, settings))
{
newDataSet.ReadXml(reader);
}
dataGrid.DataSource = newDataSet;
I added a xsd schema to my project and used MSDataSetGenerator to generate the newDataSet. (VS2008).
Now i want to create a new DataSet object for every new (hierarchical xml) file i read.
Creating a new DataSet object isn’t a problem but the data types aren ‘t correct, so i can’t sort them well (specifically the numerical fields). In my view, i need to create a new Typed DataSet.
So how can i fix this ?
Let me answer my own question ;-))
A typed DataSet is simply a class you can instantiate like any other class.There is no magic to anything generated by tools, those tools simply generate classes and you can use those classes the same way you use other classes.
Do
NewDataSet d1 = new NewDataSet();where you put the right class name there instead of “NewDataSet”.