DataSet.ReadXmlSchema Metodo

Definizione

Legge un XML Schema in DataSet.

Overload

ReadXmlSchema(Stream)

Legge lo schema XML dalla classe Stream specificata nella classe DataSet.

ReadXmlSchema(TextReader)

Legge lo schema XML dalla classe TextReader specificata nella classe DataSet.

ReadXmlSchema(String)

Legge lo schema XML dal file specificato nell'oggetto DataSet.

ReadXmlSchema(XmlReader)

Legge lo schema XML dalla classe XmlReader specificata nella classe DataSet.

ReadXmlSchema(Stream)

Legge lo schema XML dalla classe Stream specificata nella classe 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)

Parametri

stream
Stream

Classe Stream da cui eseguire la lettura.

Esempio

Nell'esempio seguente viene creato un oggetto per leggere uno FileStream schema XML con e richiama il metodo con l'oggetto ReadXmlSchema .

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

Commenti

Usare il metodo per creare lo ReadXmlSchema schema per un DataSetoggetto . Lo schema include definizioni di tabella, relazione e vincolo. Per scrivere uno schema in un documento XML, usare il WriteXmlSchema metodo .

Lo schema XML viene scritto usando lo standard XSD.

Nota

Il danneggiamento dei dati può verificarsi se msdata:DataType e i tipi xs:type non corrispondono. Nessuna eccezione verrà generata.

Il ReadXmlSchema metodo viene in genere richiamato prima di richiamare il ReadXml metodo utilizzato per riempire l'oggetto DataSet.

Le classi derivate dalla Stream classe includono BufferedStream, , FileStreamMemoryStreame NetworkStream.

Nota

Se lo schema per DataSet l'oggetto contiene elementi dello stesso nome, ma un tipo diverso, nello stesso spazio dei nomi, viene generata un'eccezione quando si tenta di leggere lo schema in DataSet con ReadXmlSchema. Questa eccezione non si verifica se si usa .NET Framework versione 1.0.

Vedi anche

Si applica a

ReadXmlSchema(TextReader)

Legge lo schema XML dalla classe TextReader specificata nella classe 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)

Parametri

reader
TextReader

Classe TextReader da cui eseguire la lettura.

Esempio

L'esempio seguente crea un oggetto con cui leggere uno StreamReader schema e richiama il ReadXmlSchema metodo con l'oggetto .

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

Commenti

Usare il metodo per creare lo ReadXmlSchema schema per un DataSetoggetto . Lo schema include definizioni di tabella, relazione e vincolo. Per scrivere uno schema in un documento XML, usare il WriteXmlSchema metodo .

Lo schema XML viene scritto usando lo standard XSD.

Nota

Il danneggiamento dei dati può verificarsi se msdata:DataType e i tipi xs:type non corrispondono. Nessuna eccezione verrà generata.

Il ReadXmlSchema metodo viene in genere richiamato prima di richiamare il ReadXml metodo utilizzato per riempire l'oggetto DataSet.

Le classi che ereditano dalla TextReader classe includono le StreamReader classi e StringReader .

Nota

Se lo schema per DataSet l'oggetto contiene elementi dello stesso nome, ma un tipo diverso, nello stesso spazio dei nomi, viene generata un'eccezione quando si tenta di leggere lo schema in DataSet con ReadXmlSchema. Questa eccezione non si verifica se si usa .NET Framework versione 1.0.

Vedi anche

Si applica a

ReadXmlSchema(String)

Legge lo schema XML dal file specificato nell'oggetto DataSet.

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

Parametri

fileName
String

Nome del file, incluso il percorso, da cui eseguire la lettura.

Eccezioni

La classe FileIOPermission non è impostata su Read.

Esempio

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

Commenti

Usare il metodo per creare lo ReadXmlSchema schema per un DataSetoggetto . Lo schema include definizioni di tabella, relazione e vincolo. Per scrivere uno schema in un documento XML, usare il WriteXmlSchema metodo .

Lo schema XML viene scritto usando lo standard XSD.

Nota

Il danneggiamento dei dati può verificarsi se msdata:DataType e i tipi xs:type non corrispondono. Nessuna eccezione verrà generata.

Il ReadXmlSchema metodo viene in genere richiamato prima di richiamare il ReadXml metodo utilizzato per riempire l'oggetto DataSet.

Nota

Se lo schema per l'oggetto DataSet contiene elementi con lo stesso nome, ma di tipo diverso, nello stesso spazio dei nomi, quando si tenta di leggere lo schema nell'oggetto DataSet con il metodo ReadXmlSchema verrà generata un'eccezione. Questa eccezione non si verifica se si usa .NET Framework versione 1.0.

Vedi anche

Si applica a

ReadXmlSchema(XmlReader)

Legge lo schema XML dalla classe XmlReader specificata nella classe 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)

Parametri

reader
XmlReader

Classe XmlReader da cui eseguire la lettura.

Esempio

Nell'esempio seguente viene creato un nuovo DataSet oggetto e System.IO.FileStream . L'oggetto FileStream , creato con un percorso file e un nome file, viene usato per creare un System.Xml.XmlTextReader oggetto passato come argomento al ReadXmlSchema metodo .

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

Commenti

Usare il metodo per creare lo ReadXmlSchema schema per un DataSetoggetto . Lo schema include definizioni di tabella, relazione e vincolo.

Lo schema XML viene scritto usando lo standard XSD.

Nota

Il danneggiamento dei dati può verificarsi se msdata:DataType e i tipi xs:type non corrispondono. Nessuna eccezione verrà generata.

Il ReadXmlSchema metodo viene in genere richiamato prima di richiamare il ReadXml metodo utilizzato per riempire l'oggetto DataSet.

La System.Xml.XmlReader classe è astratta. Classe che eredita dalla XmlReader classe è la System.Xml.XmlTextReader classe .

Nota

Se lo schema per DataSet l'oggetto contiene elementi dello stesso nome, ma un tipo diverso, nello stesso spazio dei nomi, viene generata un'eccezione quando si tenta di leggere lo schema in DataSet con ReadXmlSchema. Questa eccezione non si verifica se si usa .NET Framework versione 1.0.

Vedi anche

Si applica a