Bewerken

Share via


DataSet.ReadXmlSchema Method

Definition

Reads an XML schema into the DataSet.

Overloads

ReadXmlSchema(Stream)

Reads the XML schema from the specified Stream into the DataSet.

ReadXmlSchema(TextReader)

Reads the XML schema from the specified TextReader into the DataSet.

ReadXmlSchema(String)

Reads the XML schema from the specified file into the DataSet.

ReadXmlSchema(XmlReader)

Reads the XML schema from the specified XmlReader into the DataSet.

ReadXmlSchema(Stream)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified Stream into the DataSet.

public:
 void ReadXmlSchema(System::IO::Stream ^ stream);
public void ReadXmlSchema (System.IO.Stream? stream);
public void ReadXmlSchema (System.IO.Stream stream);
member this.ReadXmlSchema : System.IO.Stream -> unit
Public Sub ReadXmlSchema (stream As Stream)

Parameters

stream
Stream

The Stream from which to read.

Examples

The following example creates a FileStream object to read an XML schema with, and invokes the ReadXmlSchema method with the object.

private void ReadSchemaFromFileStream(DataSet thisDataSet)
{
    // Set the file path and name.
    // Modify this for your purposes.
    string filename="Schema.xml";

    // Create the FileStream object with the file name,
    // and set to open the file.
    System.IO.FileStream stream =
        new System.IO.FileStream(filename,System.IO.FileMode.Open);

    // Read the schema into the DataSet.
    thisDataSet.ReadXmlSchema(stream);

    // Close the FileStream.
    stream.Close();
}
Private Sub ReadSchemaFromFileStream(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Create the FileStream object with the file name, 
    ' and set to open the file
    Dim stream As New System.IO.FileStream _
        (filename, System.IO.FileMode.Open)

    ' Read the schema into the DataSet.
    thisDataSet.ReadXmlSchema(stream)

    ' Close the FileStream.
    stream.Close()
End Sub

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

Classes that derive from the Stream class include BufferedStream, FileStream, MemoryStream, and NetworkStream.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

ReadXmlSchema(TextReader)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified TextReader into the DataSet.

public:
 void ReadXmlSchema(System::IO::TextReader ^ reader);
public void ReadXmlSchema (System.IO.TextReader? reader);
public void ReadXmlSchema (System.IO.TextReader reader);
member this.ReadXmlSchema : System.IO.TextReader -> unit
Public Sub ReadXmlSchema (reader As TextReader)

Parameters

reader
TextReader

The TextReader from which to read.

Examples

The following example creates a StreamReader object to read a schema with, and invokes the ReadXmlSchema method with the object.

private void ReadSchemaFromStreamReader()
{
    // Create the DataSet to read the schema into.
    DataSet thisDataSet = new DataSet();

    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create a StreamReader object with the file path and name.
    System.IO.StreamReader readStream =
        new System.IO.StreamReader(filename);

    // Invoke the ReadXmlSchema method with the StreamReader object.
    thisDataSet.ReadXmlSchema(readStream);

    // Close the StreamReader
    readStream.Close();
}
Private Sub ReadSchemaFromStreamReader()
    ' Create the DataSet to read the schema into.
    Dim thisDataSet As New DataSet()

    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Create a StreamReader object with the file path and name.
    Dim readStream As New System.IO.StreamReader(filename)

    ' Invoke the ReadXmlSchema method with the StreamReader object.
    thisDataSet.ReadXmlSchema(readStream)

    ' Close the StreamReader
    readStream.Close()
End Sub

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

Classes that inherit from the TextReader class include the StreamReader and StringReader classes.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

ReadXmlSchema(String)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified file into the DataSet.

public:
 void ReadXmlSchema(System::String ^ fileName);
public void ReadXmlSchema (string fileName);
member this.ReadXmlSchema : string -> unit
Public Sub ReadXmlSchema (fileName As String)

Parameters

fileName
String

The file name (including the path) from which to read.

Exceptions

Examples

private void ReadSchemaFromFile(){
   // Create the DataSet to read the schema into.
   DataSet thisDataSet = new DataSet();

   // Set the file path and name. Modify this for your purposes.
   string filename="Schema.xml";

   // Invoke the ReadXmlSchema method with the file name.
   thisDataSet.ReadXmlSchema(filename);
}
Private Sub ReadSchemaFromFile()
    ' Create the DataSet to read the schema into.
    Dim thisDataSet As New DataSet()

    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Invoke the ReadXmlSchema method with the file name.
    thisDataSet.ReadXmlSchema(filename)
End Sub

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

ReadXmlSchema(XmlReader)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified XmlReader into the DataSet.

public:
 void ReadXmlSchema(System::Xml::XmlReader ^ reader);
public void ReadXmlSchema (System.Xml.XmlReader? reader);
public void ReadXmlSchema (System.Xml.XmlReader reader);
member this.ReadXmlSchema : System.Xml.XmlReader -> unit
Public Sub ReadXmlSchema (reader As XmlReader)

Parameters

reader
XmlReader

The XmlReader from which to read.

Examples

The following example creates a new DataSet and System.IO.FileStream object. The FileStream object, created with a file path and file name, is used to create an System.Xml.XmlTextReader that is passed as an argument to the ReadXmlSchema method.

private void ReadSchemaFromXmlTextReader()
{
    // Create the DataSet to read the schema into.
    DataSet thisDataSet = new DataSet();

    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create a FileStream object with the file path and name.
    System.IO.FileStream stream = new System.IO.FileStream
        (filename,System.IO.FileMode.Open);

    // Create a new XmlTextReader object with the FileStream.
    System.Xml.XmlTextReader xmlReader=
        new System.Xml.XmlTextReader(stream);

    // Read the schema into the DataSet and close the reader.
    thisDataSet.ReadXmlSchema(xmlReader);
    xmlReader.Close();
}
Private Sub ReadSchemaFromXmlTextReader()
    ' Create the DataSet to read the schema into.
    Dim thisDataSet As New DataSet()

    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Create a FileStream object with the file path and name.
    Dim stream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Open)

    ' Create a new XmlTextReader object with the FileStream.
    Dim xmlReader As New System.Xml.XmlTextReader(stream)

    ' Read the schema into the DataSet and close the reader.
    thisDataSet.ReadXmlSchema(xmlReader)
    xmlReader.Close()
End Sub

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

The System.Xml.XmlReader class is abstract. A class that inherits from the XmlReader is the System.Xml.XmlTextReader class.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to