次の方法で共有


DataSet.WriteXmlSchema メソッド (TextWriter)

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

Overloads Public Sub WriteXmlSchema( _
   ByVal writer As TextWriter _)
[C#]
public void WriteXmlSchema(TextWriterwriter);
[C++]
public: void WriteXmlSchema(TextWriter* writer);
[JScript]
public function WriteXmlSchema(
   writer : TextWriter);

パラメータ

  • writer
    書き込みに使用する TextWriter オブジェクト。

解説

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

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

XML ドキュメントにデータを書き込むには、 WriteXml メソッドを使用します。

System.IO.TextWriter クラスの派生クラスには、 System.Web.HttpWriterSystem.CodeDOM.Compiler.IndentedTextWriterSystem.Web.UI.HtmlTextWriterSystem.IO.StreamWriter 、および System.IO.StringWriter が含まれます。

使用例

[Visual Basic, C#, C++] 新しい System.IO.StringWriter の作成に使用される System.Text.StringBuilder オブジェクトを作成する例を次に示します。 StringWriterWriteXmlSchema メソッドに渡され、結果の文字列がコンソール ウィンドウに出力されます。

 
Private Sub WriteSchemaWithStringWriter(thisDataSet As DataSet)
    ' Create a new StringBuilder object.
    Dim mysb As New System.Text.StringBuilder()
    ' Create the StringWriter object with the StringBuilder object.
    Dim myStringWriter As New System.IO.StringWriter(mysb)
    ' Write the schema into the StringWriter.
    thisDataSet.WriteXmlSchema(myStringWriter)
    ' Print the string to the console window.
    Console.WriteLine(myStringWriter.ToString())
End Sub

[C#] 
private void WriteSchemaWithStringWriter(DataSet thisDataSet){
   // Create a new StringBuilder object.
   System.Text.StringBuilder mysb = new System.Text.StringBuilder();
   // Create the StringWriter object with the StringBuilder object.
   System.IO.StringWriter myStringWriter = new System.IO.StringWriter(mysb);
   // Write the schema into the StringWriter.
   thisDataSet.WriteXmlSchema(myStringWriter);
   // Print the string to the console window.
   Console.WriteLine(myStringWriter.ToString());
}

[C++] 
private:
 void WriteSchemaWithStringWriter(DataSet* thisDataSet){
    // Create a new StringBuilder object.
    System::Text::StringBuilder* mysb = new System::Text::StringBuilder();
    // Create the StringWriter object with the StringBuilder object.
    System::IO::StringWriter* myStringWriter = new System::IO::StringWriter(mysb);
    // Write the schema into the StringWriter.
    thisDataSet->WriteXmlSchema(myStringWriter);
    // Print the string to the console window.
    Console::WriteLine(myStringWriter);
 }

[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.WriteXmlSchema オーバーロードの一覧 | ReadXml | ReadXmlSchema | WriteXml