Sunday 16 February 2014

XML and DataSet items

This article will have a look at DataSet objects and how XML can be used while running with datasets. Let's start by exploring what a dataSet is.

A dataSet is effectively an in-memory illustration of information, for the reason that data itself can be stored to memory, it may be changed and it can be written back to the data supply.

It may possibly additionally include a number of datatable items. The DataTable items themselves may have rows and columns, recognized as dataRows and dataColumns as well as a primary key, foreign key, and constraint and also relation information about the knowledge within the informationtable items. 

The datatable item represents every table inside a dataSet; and as a result the dataColumn object every column within a datatable and  the dataRow item every row within a datatable. 

It is usually vital to understand that the DataSet does not validate the XML data against the schema; it simply uses it to infer the construction required for the tables within the DataSet.  The utility data.DataSet magnificence is equipped to strengthen dataSet in .NET.

What’s the DataSet class in .Net?

The dataSet class in .net is a rather useful .net feature that allows you to construct programs and store data in an XML report fairly than having to store retrieve it from a knowledgebase.


This is possible thanks to the extensive XML support featured in the DataSet class for reading and writing data as XML, this includes the following methods which I will explain in detail, GetXml Method,  GetXmlSchema Method, InferXmlSchema Method, WriteXml Method, WriteXmlSchema Method, ReadXml Method, ReadXmlSchema Method.

So let’s take a look at each of those methods in a little more detail, i will be able to show you the right kind of syntax as well.

The GetXml Method

This means returns a string that accommodates an XML illustration of the particular data that is saved in the DataSet, the syntax is public string GetXml();

The GetXmlSchema Method

This method returns the schema for an XML representation of the data stored in the DataSet, it returns the XML as a string so its more verbose than the WriteXmlSchema method to write XML to a file.  The syntax is public string GetXmlSchema();

InferXmlSchema Method

This method applies XML schema to the DataSet by means of taking an XML file supplied in a TextReader, XmlReader, flow item or a unique disk file. The syntax is;

public void InferXmlSchema(string,string[]);
public void InferXmlSchema(TextReader,string[]);
public void InferXmlSchema(Stream,Stream[]);
public void InferXmlSchema(XmlReader,string[]);

WriteXml Method

This method writes the XML representation of the data in the DataSet object to a TextWriter object, an XmlWriter object, a Stream object or directly to a specified disk file.  The syntax is;

public void WriteXml(string);
public void WriteXml(TextWriter);
public void WriteXml(Stream);
public void WriteXml(XmlWriter);

WriteXmlSchema Method

This manner writes the XML schema of the DataSet to a TextWriter item, an XmlWriter object, a move item or instantly to a unique disk document.  The syntax is;

public void WriteXmlSchema(string);
public void WriteXmlSchema(TextWriter);
public void WriteXmlSchema(Stream);
public void WriteXmlSchema(XmlWriter);

ReadXml Method

This manner reads the XML information (including a schema when present) into the DataSet from a TextReader, XmlReader, move object or directly to a certaindisk file.  The syntax is;

public void ReadXml(string);
public void ReadXml(TextReader);
public void ReadXml(Stream);
public void ReadXml(XmlReader);

ReadXmlSchema Method

This means reads the XML schema describing the contents of the DataSet to a TextReader, XmlReader, and stream item or right away to a particular disk document. The syntax is;

public void ReadXmlSchema(string);
public void ReadXmlSchema(TextReader);
public void ReadXmlSchema(Stream);
public void ReadXmlSchema(XmlReader);

You should also endure mind that the above methods with DataSet are more suited for running with small quantities of information on account of the amount of memory that may be required, operating quite a lot of knowledge this will likely quickly weigh down any huge utility.