次の方法で共有


DataSet.ReadXmlSchema メソッド (Stream)

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

Overloads Public Sub ReadXmlSchema( _
   ByVal stream As Stream _)
[C#]
public void ReadXmlSchema(Streamstream);
[C++]
public: void ReadXmlSchema(Stream* stream);
[JScript]
public function ReadXmlSchema(
   stream : Stream);

パラメータ

  • stream
    読み込み元の Stream

解説

ReadXmlSchema メソッドを使用して、 DataSet のスキーマを作成します。スキーマにはテーブル、リレーションシップ、制約の各定義が含まれています。XML ドキュメントにスキーマを書き込むには、 WriteXmlSchema メソッドを使用します。

XML スキーマの書き込みには、XSD 標準を使用します。

通常、 ReadXmlSchema メソッドは、 DataSet への格納に使用する ReadXml メソッドの呼び出しの前に呼び出されます。

Stream クラスの派生クラスには、 BufferedStreamFileStreamMemoryStream 、および NetworkStream が含まれます。

メモ    DataSet のスキーマに、同じ名前空間で名前が同じであるが型が違う要素が含まれている場合、スキーマを ReadXmlSchemaDataSet に読み込もうとすると、例外がスローされます。この例外は、.NET Framework Version 1.0 を使用している場合は発生しません。

使用例

[Visual Basic, C#, C++] XML スキーマの読み込みに使用する FileStream オブジェクトを作成し、このオブジェクトで ReadXmlSchema メソッドを呼び出す例を次に示します。

 
Private Sub ReadSchemaFromFileStream(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "mySchema.xml"
    ' Create the FileStream object with the file name, and set to open the file
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Open)
    ' Read the schema into the DataSet.
    thisDataSet.ReadXmlSchema(myFileStream)
    ' Close the FileStream.
    myFileStream.Close()
End Sub

[C#] 
private void ReadSchemaFromFileStream(DataSet thisDataSet){
   // Set the file path and name. Modify this for your purposes.
   string filename="mySchema.xml";
   // Create the FileStream object with the file name, and set to open the file.
   System.IO.FileStream myFileStream = 
      new System.IO.FileStream(filename,System.IO.FileMode.Open);
   // Read the schema into the DataSet.
   thisDataSet.ReadXmlSchema(myFileStream);
   // Close the FileStream.
   myFileStream.Close();
}

[C++] 
private:
 void ReadSchemaFromFileStream(DataSet* thisDataSet){
    // Set the file path and name. Modify this for your purposes.
    String* filename=S"mySchema.xml";
    // Create the FileStream object with the file name, and set to open the file.
    System::IO::FileStream* myFileStream = 
       new System::IO::FileStream(filename,System::IO::FileMode::Open);
    // Read the schema into the DataSet.
    thisDataSet->ReadXmlSchema(myFileStream);
    // Close the FileStream.
    myFileStream->Close();
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataSet クラス | DataSet メンバ | System.Data 名前空間 | DataSet.ReadXmlSchema オーバーロードの一覧 | ReadXml | WriteXml | WriteXmlSchema