DataSet.ReadXmlSchema 方法

定義

將 XML 結構描述讀入 DataSet

多載

ReadXmlSchema(Stream)

從指定的 Stream,將 XML 結構描述讀入 DataSet

ReadXmlSchema(TextReader)

從指定的 TextReader,將 XML 結構描述讀入 DataSet

ReadXmlSchema(String)

從指定的檔案,將 XML 結構描述讀入 DataSet

ReadXmlSchema(XmlReader)

從指定的 XmlReader,將 XML 結構描述讀入 DataSet

ReadXmlSchema(Stream)

來源:
DataSet.cs
來源:
DataSet.cs
來源:
DataSet.cs

從指定的 Stream,將 XML 結構描述讀入 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)

參數

stream
Stream

要讀取的來源 Stream

範例

下列範例會 FileStream 建立 物件來讀取 XML 架構,並使用 物件叫 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

備註

ReadXmlSchema使用方法來建立的DataSet架構。 架構包含數據表、關聯性和條件約束定義。 若要將架構寫入 XML 檔,請使用 WriteXmlSchema 方法。

XML 架構是使用 XSD 標準來撰寫。

注意

如果 msdata:DataType 和 xs:type 類型不相符,可能會發生數據損毀。 不會擲回例外狀況。

ReadXmlSchemaReadXml 用 用來填滿 DataSet的方法之前,通常會叫用 方法。

衍生自類別的 Stream 類別包括 BufferedStreamFileStreamMemoryStreamNetworkStream

注意

如果您的架構 DataSet 包含相同名稱但類型不同的元素,在相同的命名空間中,當您嘗試使用 將架構讀取至 DataSetReadXmlSchema時,就會擲回例外狀況。 如果您使用 .NET Framework 1.0 版,則不會發生此例外狀況。

另請參閱

適用於

ReadXmlSchema(TextReader)

來源:
DataSet.cs
來源:
DataSet.cs
來源:
DataSet.cs

從指定的 TextReader,將 XML 結構描述讀入 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)

參數

reader
TextReader

要讀取的來源 TextReader

範例

下列範例會 StreamReader 建立 物件來讀取架構,並使用 物件叫 ReadXmlSchema 用 方法。

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

備註

ReadXmlSchema使用方法來建立的DataSet架構。 架構包含數據表、關聯性和條件約束定義。 若要將架構寫入 XML 檔,請使用 WriteXmlSchema 方法。

XML 架構是使用 XSD 標準來撰寫。

注意

如果 msdata:DataType 和 xs:type 類型不相符,可能會發生數據損毀。 不會擲回例外狀況。

ReadXmlSchemaReadXml 用 用來填滿 DataSet的方法之前,通常會叫用 方法。

繼承自類別的 TextReader 類別包括 StreamReaderStringReader 類別。

注意

如果您的架構 DataSet 包含相同名稱但類型不同的元素,在相同的命名空間中,當您嘗試使用 將架構讀取至 DataSetReadXmlSchema時,就會擲回例外狀況。 如果您使用 .NET Framework 1.0 版,則不會發生此例外狀況。

另請參閱

適用於

ReadXmlSchema(String)

來源:
DataSet.cs
來源:
DataSet.cs
來源:
DataSet.cs

從指定的檔案,將 XML 結構描述讀入 DataSet

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

參數

fileName
String

要讀取的來源檔案名稱 (包括路徑)。

例外狀況

FileIOPermission 並不是設定為 Read

範例

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

備註

ReadXmlSchema使用方法來建立的DataSet架構。 架構包含數據表、關聯性和條件約束定義。 若要將架構寫入 XML 檔,請使用 WriteXmlSchema 方法。

XML 架構是使用 XSD 標準來撰寫。

注意

如果 msdata:DataType 和 xs:type 類型不相符,可能會發生數據損毀。 不會擲回例外狀況。

ReadXmlSchemaReadXml 用 用來填滿 DataSet的方法之前,通常會叫用 方法。

注意

如果您的架構 DataSet 包含相同名稱的專案,但類型不同,在相同的命名空間中,當您嘗試使用 將架構讀取至 DataSetReadXmlSchema時,就會擲回例外狀況。 如果您使用 .NET Framework 1.0 版,則不會發生此例外狀況。

另請參閱

適用於

ReadXmlSchema(XmlReader)

來源:
DataSet.cs
來源:
DataSet.cs
來源:
DataSet.cs

從指定的 XmlReader,將 XML 結構描述讀入 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)

參數

reader
XmlReader

要讀取的來源 XmlReader

範例

下列範例會建立新的 DataSetSystem.IO.FileStream 物件。 使用 FileStream 檔案路徑與檔案名稱所建立的物件,可用來建立 System.Xml.XmlTextReader 傳遞為 方法自變數的 ReadXmlSchema

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

備註

ReadXmlSchema使用方法來建立的DataSet架構。 架構包含數據表、關聯性和條件約束定義。

XML 架構是使用 XSD 標準來撰寫。

注意

如果 msdata:DataType 和 xs:type 類型不相符,可能會發生數據損毀。 不會擲回例外狀況。

ReadXmlSchemaReadXml 用 用來填滿 DataSet的方法之前,通常會叫用 方法。

類別 System.Xml.XmlReader 是抽象的。 繼承自 XmlReaderSystem.Xml.XmlTextReader 類別是 類別。

注意

如果您的架構 DataSet 包含相同名稱但類型不同的元素,在相同的命名空間中,當您嘗試使用 將架構讀取至 DataSetReadXmlSchema時,就會擲回例外狀況。 如果您使用 .NET Framework 1.0 版,則不會發生此例外狀況。

另請參閱

適用於