DataSet.WriteXmlSchema DataSet.WriteXmlSchema DataSet.WriteXmlSchema DataSet.WriteXmlSchema Method

定义

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

重载

WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>)

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

WriteXmlSchema(Stream) WriteXmlSchema(Stream) WriteXmlSchema(Stream)

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

WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter)

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

WriteXmlSchema(String) WriteXmlSchema(String) WriteXmlSchema(String) WriteXmlSchema(String)

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

WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter)

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

WriteXmlSchema(Stream, Converter<Type,String>) WriteXmlSchema(Stream, Converter<Type,String>) 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>) WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,String>)

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

WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>)

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

WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) 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 String String String

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

multipleTargetConverter
Converter<Type,String>

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

WriteXmlSchema(Stream) WriteXmlSchema(Stream) 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

参数

stream
Stream 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

注解

使用方法可将的架构DataSet写入 XML 文档。 WriteXmlSchemaUse 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) WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter) 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 TextWriter TextWriter

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

示例

下面的示例创建一个System.Text.StringBuilder用于创建新System.IO.StringWriter的对象。The 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

注解

使用方法可将的架构DataSet写入 XML 文档。 WriteXmlSchemaUse 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.IndentedTextWriterSystem.Web.UI.HtmlTextWriter System.IO.StreamWriter、和System.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) WriteXmlSchema(String) WriteXmlSchema(String) 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 String String 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

注解

使用方法可将的架构DataSet写入 XML 文档。 WriteXmlSchemaUse 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.

安全性

FileIOPermission
用于读取和写入文件。for reading and writing files. 关联的枚举:FileIOPermissionAccessAssociated enumeration: FileIOPermissionAccess

另请参阅

WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) 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 XmlWriter XmlWriter 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. 然后,XmlTextWriter通过对象调用方法,将WriteXmlSchema架构写入磁盘。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

注解

使用方法可将的架构DataSet写入 XML 文档。 WriteXmlSchemaUse 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.XmlWriter类的一个类XmlTextWriter是类。One class that inherits from the System.Xml.XmlWriter class is the XmlTextWriter class.

另请参阅

WriteXmlSchema(Stream, Converter<Type,String>) WriteXmlSchema(Stream, Converter<Type,String>) 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);
member this.WriteXmlSchema : System.IO.Stream * Converter<Type, string> -> unit

参数

stream
Stream Stream 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>) WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,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);
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 TextWriter 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>) WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,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);
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 XmlWriter XmlWriter

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

multipleTargetConverter
Converter<Type,String>

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

适用于