(Examples in C#)
First we need to write the original dataset to an XML-file.
using System.Xml;
using System.Xml.Serialization;
using System.IO;
XmlSerializer ser = new XmlSerializer(typeof (DataSet));
XmlTextWriter wrt = new XmlTextWriter(@"filename.XML",null);
ser.Serialize (wrt, yourDataSet);
Run this code once to create an XML file of your dataset.
Then start the Visual Studio Command prompt.
Create the XSD schema file using the XSD.EXE tool.
xsd filename.xml
This creates the schema file filename.xsd.
Now use the same tool to create the class for the typed dataset;
xsd /d /l:CS filename.xsd
Add the created file filename.cs to your project.
Use this new class instead of the normal dataset.
No comments:
Post a Comment