DataSet.ReadXmlSchema Metoda

Definicja

Odczytuje schemat XML do elementu DataSet.

Przeciążenia

ReadXmlSchema(Stream)

Odczytuje schemat XML z określonego Stream elementu do .DataSet

ReadXmlSchema(TextReader)

Odczytuje schemat XML z określonego TextReader elementu do .DataSet

ReadXmlSchema(String)

Odczytuje schemat XML z określonego pliku do pliku DataSet.

ReadXmlSchema(XmlReader)

Odczytuje schemat XML z określonego XmlReader elementu do .DataSet

ReadXmlSchema(Stream)

Odczytuje schemat XML z określonego Stream elementu do .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)

Parametry

stream
Stream

Element Stream , z którego mają być odczytywane.

Przykłady

Poniższy przykład tworzy FileStream obiekt do odczytywania schematu XML za pomocą metody i wywołuje metodę ReadXmlSchema z obiektem .

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

Uwagi

ReadXmlSchema Użyj metody , aby utworzyć schemat dla elementu DataSet. Schemat zawiera definicje tabel, relacji i ograniczeń. Aby napisać schemat do dokumentu XML, użyj WriteXmlSchema metody .

Schemat XML jest zapisywany przy użyciu standardu XSD.

Uwaga

Uszkodzenie danych może wystąpić, jeśli typy msdata:DataType i xs:type nie są zgodne. Nie zostanie zgłoszony żaden wyjątek.

Metoda ReadXmlSchema jest zwykle wywoływana przed wywołaniem ReadXml metody , która jest używana do wypełnienia metody DataSet.

Klasy pochodzące z Stream klasy obejmują BufferedStream, FileStream, MemoryStreami NetworkStream.

Uwaga

Jeśli schemat zawiera DataSet elementy o tej samej nazwie, ale inny typ, w tej samej przestrzeni nazw, podczas próby odczytania schematu do elementu DataSet ReadXmlSchemaza pomocą polecenia zostanie zgłoszony wyjątek. Ten wyjątek nie występuje, jeśli używasz .NET Framework w wersji 1.0.

Zobacz też

Dotyczy

ReadXmlSchema(TextReader)

Odczytuje schemat XML z określonego TextReader elementu do .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)

Parametry

reader
TextReader

Element TextReader , z którego mają być odczytywane.

Przykłady

Poniższy przykład tworzy StreamReader obiekt do odczytywania schematu za pomocą metody i wywołuje ReadXmlSchema metodę z obiektem .

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

Uwagi

ReadXmlSchema Użyj metody , aby utworzyć schemat dla elementu DataSet. Schemat zawiera definicje tabel, relacji i ograniczeń. Aby napisać schemat do dokumentu XML, użyj WriteXmlSchema metody .

Schemat XML jest zapisywany przy użyciu standardu XSD.

Uwaga

Uszkodzenie danych może wystąpić, jeśli typy msdata:DataType i xs:type nie są zgodne. Nie zostanie zgłoszony żaden wyjątek.

Metoda ReadXmlSchema jest zwykle wywoływana przed wywołaniem ReadXml metody , która jest używana do wypełnienia metody DataSet.

Klasy dziedziczone z TextReader klasy obejmują StreamReader klasy i StringReader .

Uwaga

Jeśli schemat zawiera DataSet elementy o tej samej nazwie, ale inny typ, w tej samej przestrzeni nazw, podczas próby odczytania schematu do elementu DataSet ReadXmlSchemaza pomocą polecenia zostanie zgłoszony wyjątek. Ten wyjątek nie występuje, jeśli używasz .NET Framework w wersji 1.0.

Zobacz też

Dotyczy

ReadXmlSchema(String)

Odczytuje schemat XML z określonego pliku do pliku DataSet.

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

Parametry

fileName
String

Nazwa pliku (w tym ścieżka), z której ma być odczytywany.

Wyjątki

FileIOPermission nie jest ustawiona na Readwartość .

Przykłady

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

Uwagi

ReadXmlSchema Użyj metody , aby utworzyć schemat dla elementu DataSet. Schemat zawiera definicje tabel, relacji i ograniczeń. Aby napisać schemat do dokumentu XML, użyj WriteXmlSchema metody .

Schemat XML jest zapisywany przy użyciu standardu XSD.

Uwaga

Uszkodzenie danych może wystąpić, jeśli typy msdata:DataType i xs:type nie są zgodne. Nie zostanie zgłoszony żaden wyjątek.

Metoda ReadXmlSchema jest zwykle wywoływana przed wywołaniem ReadXml metody , która jest używana do wypełnienia metody DataSet.

Uwaga

Jeśli schemat zawiera DataSet elementy o tej samej nazwie, ale inny typ, w tej samej przestrzeni nazw, podczas próby odczytania schematu do elementu DataSet ReadXmlSchemaza pomocą polecenia zostanie zgłoszony wyjątek. Ten wyjątek nie występuje, jeśli używasz .NET Framework w wersji 1.0.

Zobacz też

Dotyczy

ReadXmlSchema(XmlReader)

Odczytuje schemat XML z określonego XmlReader elementu do .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)

Parametry

reader
XmlReader

Element XmlReader , z którego mają być odczytywane.

Przykłady

Poniższy przykład tworzy nowy DataSet obiekt i System.IO.FileStream . Obiekt FileStream , utworzony przy użyciu ścieżki pliku i nazwy pliku, służy do tworzenia System.Xml.XmlTextReader obiektu, który jest przekazywany jako argument do ReadXmlSchema metody.

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

Uwagi

ReadXmlSchema Użyj metody , aby utworzyć schemat dla elementu DataSet. Schemat zawiera definicje tabel, relacji i ograniczeń.

Schemat XML jest zapisywany przy użyciu standardu XSD.

Uwaga

Uszkodzenie danych może wystąpić, jeśli typy msdata:DataType i xs:type nie są zgodne. Nie zostanie zgłoszony żaden wyjątek.

Metoda ReadXmlSchema jest zwykle wywoływana przed wywołaniem ReadXml metody , która jest używana do wypełnienia metody DataSet.

Klasa jest abstrakcyjna System.Xml.XmlReader . Klasa dziedziczona z XmlReader klasy jest klasą System.Xml.XmlTextReader .

Uwaga

Jeśli schemat zawiera DataSet elementy o tej samej nazwie, ale inny typ, w tej samej przestrzeni nazw, podczas próby odczytania schematu do elementu DataSet ReadXmlSchemaza pomocą polecenia zostanie zgłoszony wyjątek. Ten wyjątek nie występuje, jeśli używasz .NET Framework w wersji 1.0.

Zobacz też

Dotyczy