DataSet.WriteXmlSchema 方法

定义

写 XML 架构形式的 DataSet 结构。Writes the DataSet structure as an XML schema.

重载

WriteXmlSchema(String, Converter<Type,String>)

将 XML 架构形式的 DataSet 结构写入文件。Writes the DataSet structure as an XML schema to a file.

WriteXmlSchema(Stream)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。Writes the DataSet structure as an XML schema to the specified Stream object.

WriteXmlSchema(TextWriter)

DataSet 结构作为 XML 架构写入指定的 TextWriter 对象。Writes the DataSet structure as an XML schema to the specified TextWriter object.

WriteXmlSchema(String)

将 XML 架构形式的 DataSet 结构写入文件。Writes the DataSet structure as an XML schema to a file.

WriteXmlSchema(XmlWriter)

将 XML 架构形式的 DataSet 结构写入 XmlWriter 对象。Writes the DataSet structure as an XML schema to an XmlWriter object.

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。Writes the DataSet structure as an XML schema to the specified Stream object.

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 TextWriterWrites the DataSet structure as an XML schema to the specified TextWriter.

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 XmlWriterWrites the DataSet structure as an XML schema to the specified XmlWriter.

WriteXmlSchema(String, Converter<Type,String>)

将 XML 架构形式的 DataSet 结构写入文件。Writes the DataSet structure as an XML schema to a file.

public:
 void WriteXmlSchema(System::String ^ fileName, Converter<Type ^, System::String ^> ^ multipleTargetConverter);
public void WriteXmlSchema (string fileName, Converter<Type,string> multipleTargetConverter);
member this.WriteXmlSchema : string * Converter<Type, string> -> unit
Public Sub WriteXmlSchema (fileName As String, multipleTargetConverter As Converter(Of Type, String))

参数

fileName
String

要写入的文件的名称。The name of the file to write to.

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。A delegate used to convert Type to string.

适用于

WriteXmlSchema(Stream)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。Writes the DataSet structure as an XML schema to the specified Stream object.

public:
 void WriteXmlSchema(System::IO::Stream ^ stream);
public void WriteXmlSchema (System.IO.Stream stream);
member this.WriteXmlSchema : System.IO.Stream -> unit
Public Sub WriteXmlSchema (stream As Stream)

参数

stream
Stream

用于写入文件的 Stream 对象。A Stream object used to write to a file.

示例

下面的示例创建一个新 FileStream 的对象,该对象传递给 WriteXmlSchema 方法,以便将架构写入磁盘。The following example creates a new FileStream object that is passed to the WriteXmlSchema method to write the schema to disk.

private void WriteSchemaWithFileStream(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create the FileStream object with the file name.
    // Use FileMode.Create.
    System.IO.FileStream stream =
        new System.IO.FileStream(filename,System.IO.FileMode.Create);

    // Write the schema to the file.
    thisDataSet.WriteXmlSchema(stream);

    // Close the FileStream.
    stream.Close();
}
Private Sub WriteSchemaWithFileStream(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Create the FileStream object with the file name. 
    ' Use FileMode.Create.
    Dim stream As New System.IO.FileStream _
        (filename, System.IO.FileMode.Create)

    ' Write the schema to the file.
    thisDataSet.WriteXmlSchema(stream)

    ' Close the FileStream.
    stream.Close()
End Sub

注解

使用 WriteXmlSchema 方法可将的架构写入 DataSet XML 文档。Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. 此架构包括表、关系和约束定义。The schema includes table, relation, and constraint definitions. 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。To write a schema to an XML document, use the WriteXmlSchema method.

使用 XSD 标准编写 XML 架构。The XML schema is written using the XSD standard.

若要将数据写入 XML 文档,请使用 WriteXml 方法。To write the data to an XML document, use the WriteXml method.

派生自类的类 Stream 包括 BufferedStreamFileStreamMemoryStreamNetworkStreamClasses that derive from the Stream class include BufferedStream, FileStream, MemoryStream, and NetworkStream.

另请参阅

适用于

WriteXmlSchema(TextWriter)

DataSet 结构作为 XML 架构写入指定的 TextWriter 对象。Writes the DataSet structure as an XML schema to the specified TextWriter object.

public:
 void WriteXmlSchema(System::IO::TextWriter ^ writer);
public void WriteXmlSchema (System.IO.TextWriter writer);
member this.WriteXmlSchema : System.IO.TextWriter -> unit
Public Sub WriteXmlSchema (writer As TextWriter)

参数

writer
TextWriter

要进行写入的 TextWriter 对象。The TextWriter object with which to write.

示例

下面的示例创建一个用于 System.Text.StringBuilder 创建新的对象 System.IO.StringWriterThe following example creates a System.Text.StringBuilder object to that is used to create a new System.IO.StringWriter. StringWriter传递给 WriteXmlSchema 方法,生成的字符串将打印到控制台窗口。The StringWriter is passed to the WriteXmlSchema method, and the resulting string is printed to the console window.

private void WriteSchemaWithStringWriter(DataSet thisDataSet)
{
    // Create a new StringBuilder object.
    System.Text.StringBuilder builder = new System.Text.StringBuilder();

    // Create the StringWriter object with the StringBuilder object.
    System.IO.StringWriter writer = new System.IO.StringWriter(builder);

    // Write the schema into the StringWriter.
    thisDataSet.WriteXmlSchema(writer);

    // Print the string to the console window.
    Console.WriteLine(writer.ToString());
}
Private Sub WriteSchemaWithStringWriter(thisDataSet As DataSet)
    ' Create a new StringBuilder object.
    Dim builder As New System.Text.StringBuilder()

    ' Create the StringWriter object with the StringBuilder object.
    Dim writer As New System.IO.StringWriter(builder)

    ' Write the schema into the StringWriter.
    thisDataSet.WriteXmlSchema(writer)

    ' Print the string to the console window.
    Console.WriteLine(writer.ToString())
End Sub

注解

使用 WriteXmlSchema 方法可将的架构写入 DataSet XML 文档。Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. 此架构包括表、关系和约束定义。The schema includes table, relation, and constraint definitions. 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。To write a schema to an XML document, use the WriteXmlSchema method.

使用 XSD 标准编写 XML 架构。The XML schema is written using the XSD standard.

若要将数据写入 XML 文档,请使用 WriteXml 方法。To write the data to an XML document, use the WriteXml method.

派生自类的类 System.IO.TextWriter 包括 System.Web.HttpWriter 、、、 System.CodeDom.Compiler.IndentedTextWriter System.Web.UI.HtmlTextWriter System.IO.StreamWriterSystem.IO.StringWriterClasses 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.

另请参阅

适用于

WriteXmlSchema(String)

将 XML 架构形式的 DataSet 结构写入文件。Writes the DataSet structure as an XML schema to a file.

public:
 void WriteXmlSchema(System::String ^ fileName);
public void WriteXmlSchema (string fileName);
member this.WriteXmlSchema : string -> unit
Public Sub WriteXmlSchema (fileName As String)

参数

fileName
String

要向其写入的文件的名称(包括路径)。The file name (including the path) to which to write.

例外

示例

private void WriteSchemaToFile(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Write the schema to the file.
    thisDataSet.WriteXmlSchema(filename);
}
Private Sub WriteSchemaToFile(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "Schema.xml"

    ' Write the schema to the file.
    thisDataSet.WriteXmlSchema(filename)
End Sub

注解

使用 WriteXmlSchema 方法可将的架构写入 DataSet XML 文档。Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. 此架构包括表、关系和约束定义。The schema includes table, relation, and constraint definitions. 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。To write a schema to an XML document, use the WriteXmlSchema method.

使用 XSD 标准编写 XML 架构。The XML schema is written using the XSD standard.

若要将数据写入 XML 文档,请使用 WriteXml 方法。To write the data to an XML document, use the WriteXml method.

另请参阅

适用于

WriteXmlSchema(XmlWriter)

将 XML 架构形式的 DataSet 结构写入 XmlWriter 对象。Writes the DataSet structure as an XML schema to an XmlWriter object.

public:
 void WriteXmlSchema(System::Xml::XmlWriter ^ writer);
public void WriteXmlSchema (System.Xml.XmlWriter writer);
member this.WriteXmlSchema : System.Xml.XmlWriter -> unit
Public Sub WriteXmlSchema (writer As XmlWriter)

参数

writer
XmlWriter

要向其中进行写入的 XmlWriterThe XmlWriter to write to.

示例

下面的示例 System.IO.FileStream 使用指定的路径创建一个新的对象。The following example creates a new System.IO.FileStream object with the specified path. FileStream对象用于创建 XmlTextWriter 对象。The FileStream object is used to create an XmlTextWriter object. WriteXmlSchema然后,通过对象调用方法, XmlTextWriter 将架构写入磁盘。The WriteXmlSchema method is then invoked with the XmlTextWriter object to write the schema to the disk.

private void WriteSchemaWithXmlTextWriter(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="SchemaDoc.xml";

    // Create a FileStream object with the file path and name.
    System.IO.FileStream stream = new System.IO.FileStream
        (filename,System.IO.FileMode.Create);

    // Create a new XmlTextWriter object with the FileStream.
    System.Xml.XmlTextWriter writer =
        new System.Xml.XmlTextWriter(stream,
        System.Text.Encoding.Unicode);

    // Write the schema into the DataSet and close the reader.
    thisDataSet.WriteXmlSchema(writer );
    writer.Close();
}
Private Sub WriteSchemaWithXmlTextWriter(thisDataSet As DataSet)
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "SchemaDoc.xml"

    ' Create a FileStream object with the file path and name.
    Dim stream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Create)

    ' Create a new XmlTextWriter object with the FileStream.
    Dim writer As New System.Xml.XmlTextWriter _
       (stream, System.Text.Encoding.Unicode)

    ' Write the schema into the DataSet and close the reader.
    thisDataSet.WriteXmlSchema(writer)
    writer.Close()
End Sub

注解

使用 WriteXmlSchema 方法可将的架构写入 DataSet XML 文档。Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. 此架构包括表、关系和约束定义。The schema includes table, relation, and constraint definitions. 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。To write a schema to an XML document, use the WriteXmlSchema method.

使用 XSD 标准编写 XML 架构。The XML schema is written using the XSD standard.

若要将数据写入 XML 文档,请使用 WriteXml 方法。To write the data to an XML document, use the WriteXml method.

继承自类的一个类 System.Xml.XmlWriterXmlTextWriter 类。One class that inherits from the System.Xml.XmlWriter class is the XmlTextWriter class.

另请参阅

适用于

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。Writes the DataSet structure as an XML schema to the specified Stream object.

public:
 void WriteXmlSchema(System::IO::Stream ^ stream, Converter<Type ^, System::String ^> ^ multipleTargetConverter);
public void WriteXmlSchema (System.IO.Stream? stream, Converter<Type,string> multipleTargetConverter);
public void WriteXmlSchema (System.IO.Stream stream, Converter<Type,string> multipleTargetConverter);
member this.WriteXmlSchema : System.IO.Stream * Converter<Type, string> -> unit
Public Sub WriteXmlSchema (stream As Stream, multipleTargetConverter As Converter(Of Type, String))

参数

stream
Stream

要写入到的 Stream 对象。A Stream object to write to.

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。A delegate used to convert Type to string.

适用于

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 TextWriterWrites the DataSet structure as an XML schema to the specified TextWriter.

public:
 void WriteXmlSchema(System::IO::TextWriter ^ writer, Converter<Type ^, System::String ^> ^ multipleTargetConverter);
public void WriteXmlSchema (System.IO.TextWriter? writer, Converter<Type,string> multipleTargetConverter);
public void WriteXmlSchema (System.IO.TextWriter writer, Converter<Type,string> multipleTargetConverter);
member this.WriteXmlSchema : System.IO.TextWriter * Converter<Type, string> -> unit
Public Sub WriteXmlSchema (writer As TextWriter, multipleTargetConverter As Converter(Of Type, String))

参数

writer
TextWriter

要写入到的 TextWriter 对象。A TextWriter object to write to.

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。A delegate used to convert Type to string.

适用于

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 XmlWriterWrites the DataSet structure as an XML schema to the specified XmlWriter.

public:
 void WriteXmlSchema(System::Xml::XmlWriter ^ writer, Converter<Type ^, System::String ^> ^ multipleTargetConverter);
public void WriteXmlSchema (System.Xml.XmlWriter? writer, Converter<Type,string> multipleTargetConverter);
public void WriteXmlSchema (System.Xml.XmlWriter writer, Converter<Type,string> multipleTargetConverter);
member this.WriteXmlSchema : System.Xml.XmlWriter * Converter<Type, string> -> unit
Public Sub WriteXmlSchema (writer As XmlWriter, multipleTargetConverter As Converter(Of Type, String))

参数

writer
XmlWriter

要写入到的 XmlWriter 对象。A XmlWriter object to write to.

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。A delegate used to convert Type to string.

适用于