This documentation is archived and is not being maintained.

DataSet.WriteXmlSchema Method (Stream)

.NET Framework 1.1

Writes the DataSet structure as an XML schema to using the specified System.IO.Stream object.

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

Parameters

stream
A Stream object used to write to a file.

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 that derive from the Stream class include BufferedStream, FileStream, MemoryStream, and NetworkStream.

Example

[Visual Basic, C#, C++] The following example creates a new FileStream object that is passed to the WriteXmlSchema method to write the schema to disk.

[Visual Basic] 
Private Sub WriteSchemaWithFileStream(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. Use FileMode.Create.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)
    ' Write the schema to the file.
    thisDataSet.WriteXmlSchema(myFileStream)
    ' Close the FileStream.
    myFileStream.Close()
End Sub

[C#] 
private void WriteSchemaWithFileStream(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. Use FileMode.Create.
   System.IO.FileStream myFileStream = 
      new System.IO.FileStream(filename,System.IO.FileMode.Create);
   // Write the schema to the file.
   thisDataSet.WriteXmlSchema(myFileStream);
   // Close the FileStream.
   myFileStream.Close();
}

[C++] 
private:
 void WriteSchemaWithFileStream(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. Use FileMode.Create.
    System::IO::FileStream* myFileStream = 
       new System::IO::FileStream(filename,System::IO::FileMode::Create);
    // Write the schema to the file.
    thisDataSet->WriteXmlSchema(myFileStream);
    // Close the FileStream.
    myFileStream->Close();
 }

[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 | WriteXml

Show: