This documentation is archived and is not being maintained.

DataSet.WriteXmlSchema Method (TextWriter)

.NET Framework 1.1

Writes the DataSet structure as an XML schema to a TextWriter object.

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

Parameters

writer
The TextWriter object with which to write.

Remarks

Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

To write the data to an XML document, use the WriteXml method.

Classes the derive from the System.IO.TextWriter class include the System.Web.HttpWriter, System.CodeDOM.Compiler.IndentedTextWriter, System.Web.UI.HtmlTextWriter, System.IO.StreamWriter, and System.IO.StringWriter.

Example

[Visual Basic, C#, C++] The following example creates a System.Text.StringBuilder object to that is used to create a new System.IO.StringWriter. The StringWriter is passed to the WriteXmlSchema method, and the resulting string is printed to the console window.

[Visual Basic] 
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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataSet Class | DataSet Members | System.Data Namespace | DataSet.WriteXmlSchema Overload List | ReadXml | ReadXmlSchema | WriteXml

Show: