Export (0) Print
Expand All

DataSet.WriteXmlSchema Method

Writes the DataSet structure as an XML schema.

Overload List

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

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

Writes the DataSet structure as an XML schema to a file.

Supported by the .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);

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

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

Writes the DataSet structure as an XML schema to an XmlWriter object.

Supported by the .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);

Example

[Visual Basic, C#, C++] The following example creates a new System.IO.FileStream object with the specified path. The FileStream object is used to create an System.Xml.XMLTextWriter object. The WriteXmlSchema method is then invoked with the XmlTextWriter object to write the schema to the disk.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of WriteXmlSchema. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
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] 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.

See Also

DataSet Class | DataSet Members | System.Data Namespace

Show:
© 2014 Microsoft