DataSet.ReadXmlSchema メソッド

定義

XML スキーマを DataSet に読み込みます。

オーバーロード

ReadXmlSchema(Stream)

指定した Stream から DataSet に XML スキーマを読み込みます。

ReadXmlSchema(TextReader)

指定した TextReader から DataSet に XML スキーマを読み込みます。

ReadXmlSchema(String)

指定したファイルから DataSet に XML スキーマを読み込みます。

ReadXmlSchema(XmlReader)

指定した XmlReader から DataSet に XML スキーマを読み込みます。

ReadXmlSchema(Stream)

ソース:
DataSet.cs
ソース:
DataSet.cs
ソース:
DataSet.cs

指定した Stream から DataSet に XML スキーマを読み込みます。

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 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。

メソッドはReadXmlSchema通常、 を埋DataSetめるために使用される メソッドをReadXml呼び出す前に呼び出されます。

クラスから派生するクラスには、Stream、、MemoryStreamFileStream、および NetworkStreamが含まれますBufferedStream

注意

のスキーマDataSetに同じ名前の異なる型の要素が同じ名前空間に含まれている場合は、 を使用して にスキーマを読み込DataSetReadXmlSchemaもうとしたときに例外がスローされます。 バージョン 1.0 .NET Framework使用している場合、この例外は発生しません。

こちらもご覧ください

適用対象

ReadXmlSchema(TextReader)

ソース:
DataSet.cs
ソース:
DataSet.cs
ソース:
DataSet.cs

指定した TextReader から DataSet に XML スキーマを読み込みます。

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 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。

メソッドはReadXmlSchema通常、 を埋DataSetめるために使用される メソッドをReadXml呼び出す前に呼び出されます。

クラスから継承するクラスには、 TextReader クラスと StringReader クラスがStreamReader含まれます。

注意

のスキーマDataSetに同じ名前の異なる型の要素が同じ名前空間に含まれている場合は、 を使用して にスキーマを読み込DataSetReadXmlSchemaもうとしたときに例外がスローされます。 バージョン 1.0 .NET Framework使用している場合、この例外は発生しません。

こちらもご覧ください

適用対象

ReadXmlSchema(String)

ソース:
DataSet.cs
ソース:
DataSet.cs
ソース:
DataSet.cs

指定したファイルから DataSet に XML スキーマを読み込みます。

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

パラメーター

fileName
String

読み込み元の (パスを含む) ファイル名。

例外

FileIOPermissionRead に設定されていません。

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 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。

メソッドはReadXmlSchema通常、 を埋DataSetめるために使用される メソッドをReadXml呼び出す前に呼び出されます。

注意

のスキーマDataSetに同じ名前の異なる型の要素が同じ名前空間に含まれている場合は、 を使用して にスキーマを読み取DataSetReadXmlSchemaろうとすると例外がスローされます。 バージョン 1.0 .NET Framework使用している場合、この例外は発生しません。

こちらもご覧ください

適用対象

ReadXmlSchema(XmlReader)

ソース:
DataSet.cs
ソース:
DataSet.cs
ソース:
DataSet.cs

指定した XmlReader から DataSet に XML スキーマを読み込みます。

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

次の例では、新 DataSet しい オブジェクトと オブジェクトを System.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 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。

メソッドはReadXmlSchema通常、 を埋DataSetめるために使用される メソッドをReadXml呼び出す前に呼び出されます。

クラスは System.Xml.XmlReader 抽象クラスです。 から XmlReader 継承するクラスは クラス System.Xml.XmlTextReader です。

注意

のスキーマDataSetに同じ名前の異なる型の要素が同じ名前空間に含まれている場合は、 を使用して にスキーマを読み込DataSetReadXmlSchemaもうとしたときに例外がスローされます。 バージョン 1.0 .NET Framework使用している場合、この例外は発生しません。

こちらもご覧ください

適用対象