System.Data Namespace DataSet Class
Writes the DataSet structure as an XML schema to a TextWriter object.
[ VB ]
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
);
- writer
- The TextWriter object with which to write.
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.IndentedTextWriter, System.IO.StreamWriter, and System.IO.StringWriter.
The following example initializes 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 written to the page.
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.
Response.Write ( myStringWriter.ToString ( ) );
}
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.
Response.Write ( myStringWriter.ToString ( ) )
End Sub |
|
C# |
VB |
DataSet Members DataSet.WriteXmlSchema Overload List WriteXml ReadXml ReadXmlSchema