次の方法で共有


DataSet.WriteXmlSchema メソッド

DataSet 構造体を XML スキーマとして書き込みます。

オーバーロードの一覧

指定した System.IO.Stream オブジェクトを使用して、 DataSet 構造体を XML スキーマとして書き込みます。

[Visual Basic] Overloads Public Sub WriteXmlSchema(Stream)

[C#] public void WriteXmlSchema(Stream);

[C++] public: void WriteXmlSchema(Stream*);

[JScript] public function WriteXmlSchema(Stream);

DataSet 構造体を XML スキーマとしてファイルに書き込みます。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Sub WriteXmlSchema(String)

[C#] public void WriteXmlSchema(string);

[C++] public: void WriteXmlSchema(String*);

[JScript] public function WriteXmlSchema(String);

DataSet 構造体を XML スキーマとして TextWriter オブジェクトに書き込みます。

[Visual Basic] Overloads Public Sub WriteXmlSchema(TextWriter)

[C#] public void WriteXmlSchema(TextWriter);

[C++] public: void WriteXmlSchema(TextWriter*);

[JScript] public function WriteXmlSchema(TextWriter);

DataSet 構造体を XML スキーマとして XmlWriter オブジェクトに書き込みます。

.NET Compact Framework でもサポート。

[Visual Basic] Overloads Public Sub WriteXmlSchema(XmlWriter)

[C#] public void WriteXmlSchema(XmlWriter);

[C++] public: void WriteXmlSchema(XmlWriter*);

[JScript] public function WriteXmlSchema(XmlWriter);

使用例

[Visual Basic, C#, C++] 指定したパスで新しい System.IO.FileStream オブジェクトを作成する例を次に示します。 FileStream オブジェクトを使用して System.Xml.XMLTextWriter オブジェクトを作成します。次に、 XmlTextWriter オブジェクトで WriteXmlSchema メソッドを呼び出して、ディスクにスキーマを書き込みます。

[Visual Basic, C#, C++] メモ   ここでは、WriteXmlSchema のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
Private Sub WriteSchemaWithXmlTextWriter(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "mySchema.xml"
    ' Create a FileStream object with the file path and name.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)
    ' Create a new XmlTextWriter object with the FileStream.
    Dim MyXmlTextWriter As New System.Xml.XmlTextWriter _
       (myFileStream, System.Text.Encoding.Unicode)
    ' Write the schema into the DataSet and close the reader.
    thisDataSet.WriteXmlSchema(MyXmlTextWriter)
    MyXmlTextWriter.Close()
End Sub

[C#] 
private void WriteSchemaWithXmlTextWriter(DataSet thisDataSet){
   // Set the file path and name. Modify this for your purposes.
   string filename="mySchema.xml";
   // Create a FileStream object with the file path and name.
   System.IO.FileStream myFileStream = new System.IO.FileStream
      (filename,System.IO.FileMode.Create);
   // Create a new XmlTextWriter object with the FileStream.
   System.Xml.XmlTextWriter MyXmlTextWriter = 
      new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
   // Write the schema into the DataSet and close the reader.
   thisDataSet.WriteXmlSchema(MyXmlTextWriter );
   MyXmlTextWriter.Close();
}

[C++] 
private:
 void WriteSchemaWithXmlTextWriter(DataSet* thisDataSet){
    // Set the file path and name. Modify this for your purposes.
    String* filename=S"mySchema.xml";
    // Create a FileStream object with the file path and name.
    System::IO::FileStream* myFileStream = new System::IO::FileStream
       (filename,System::IO::FileMode::Create);
    // Create a new XmlTextWriter object with the FileStream.
    System::Xml::XmlTextWriter* MyXmlTextWriter = 
       new System::Xml::XmlTextWriter(myFileStream, System::Text::Encoding::Unicode);
    // Write the schema into the DataSet and close the reader.
    thisDataSet->WriteXmlSchema(MyXmlTextWriter );
    MyXmlTextWriter->Close();
 }

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

参照

DataSet クラス | DataSet メンバ | System.Data 名前空間