Loading and Saving Schema Alone


There are times when it is desirable to load or save only the schema portion of a DataSet . For example, you might have the rows of data ready to insert into a DataSet , but you want to make sure that your data conforms to a specific schema from someone else's DataSet . The other person can save their DataSet schema. Then you can take an empty DataSet , load the other person's schema, and then insert your own data. If your data violates the schema in some way, then an exception will be thrown as you enter it into the DataSet .

To load the schema from an XML representation of a DataSet and ignore any other data, call DataSet.ReadXmlSchema() . For example:

 
 C# l_DataSet.ReadXmlSchema("\XML_DataSet.xml"); VB l_DataSet.ReadXmlSchema("\XML_DataSet.xml") 

To write only the schema information for a DataSet to XML, call DataSet.WriteXmlSchema() . For example:

 
 C# l_DataSet.WriteXmlSchema("\DataSet_SchemaOnly.xml"); VB l_DataSet.WriteXmlSchema("\DataSet_SchemaOnly.xml") 


Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net