DataSet.WriteXmlSchema 方法

定義

將結構寫 DataSet 成 XML 架構。

多載

名稱 Description
WriteXmlSchema(String, Converter<Type,String>)

DataSet 結構以 XML 架構寫入檔案。

WriteXmlSchema(Stream)

DataSet 結構以 XML 架構寫入指定的 Stream 物件。

WriteXmlSchema(TextWriter)

DataSet 結構以 XML 架構寫入指定的 TextWriter 物件。

WriteXmlSchema(String)

DataSet 結構以 XML 架構寫入檔案。

WriteXmlSchema(XmlWriter)

DataSet 結構寫成 XML 架構到 XmlWriter 物件上。

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 結構以 XML 架構寫入指定的 Stream 物件。

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 結構寫成指定的 XML 結構 TextWriter

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 結構寫成指定的 XML 結構 XmlWriter

WriteXmlSchema(String, Converter<Type,String>)

DataSet 結構以 XML 架構寫入檔案。

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

要寫入的檔案名稱。

multipleTargetConverter
Converter<Type,String>

一位代表曾轉 Type 為繩索。

適用於

WriteXmlSchema(Stream)

DataSet 結構以 XML 架構寫入指定的 Stream 物件。

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 用來寫入檔案的物件。

範例

以下範例建立一個新 FileStream 物件,該物件會傳遞給寫入結構到磁碟的方法 WriteXmlSchema

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 將 a 的結構 DataSet 寫成 XML 文件的方法。 該結構包含表格、關聯與約束定義。 要為 XML 文件撰寫結構,請使用該 WriteXmlSchema 方法。

XML 架構是依據 XSD 標準撰寫的。

若要將資料寫入 XML 文件,請使用以下 WriteXml 方法。

Stream 衍生的類別包括 BufferedStreamFileStreamMemoryStreamNetworkStream和 。

另請參閱

  • 使用 ADO.NET

適用於

WriteXmlSchema(TextWriter)

DataSet 結構以 XML 架構寫入指定的 TextWriter 物件。

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 來寫作的對象。

範例

以下範例會建立 System.Text.StringBuilder 一個物件,用來建立新的 System.IO.StringWriterStringWriter將 傳遞給WriteXmlSchema方法,產生的字串會印到主控台視窗。

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 將 a 的結構 DataSet 寫成 XML 文件的方法。 該結構包含表格、關聯與約束定義。 要為 XML 文件撰寫結構,請使用該 WriteXmlSchema 方法。

XML 架構是依據 XSD 標準撰寫的。

若要將資料寫入 XML 文件,請使用以下 WriteXml 方法。

從該System.IO.TextWriter類別推導的類別包括 System.Web.HttpWriterSystem.CodeDom.Compiler.IndentedTextWriterSystem.Web.UI.HtmlTextWriterSystem.IO.StreamWriterSystem.IO.StringWriter、 和 。

另請參閱

  • 使用 ADO.NET

適用於

WriteXmlSchema(String)

DataSet 結構以 XML 架構寫入檔案。

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

參數

fileName
String

要寫入的檔名(包括路徑)。

例外狀況

範例

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 將 a 的結構 DataSet 寫成 XML 文件的方法。 該結構包含表格、關聯與約束定義。 要為 XML 文件撰寫結構,請使用該 WriteXmlSchema 方法。

XML 架構是依據 XSD 標準撰寫的。

若要將資料寫入 XML 文件,請使用以下 WriteXml 方法。

另請參閱

  • 使用 ADO.NET

適用於

WriteXmlSchema(XmlWriter)

DataSet 結構寫成 XML 架構到 XmlWriter 物件上。

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

範例

以下範例 System.IO.FileStream 建立一個帶有指定路徑的新物件。 FileStream物件用來創造物件XmlTextWriter。 接著會用物件呼叫XmlTextWriterWriteXmlSchema方法,將結構寫入磁碟。

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 將 a 的結構 DataSet 寫成 XML 文件的方法。 該結構包含表格、關聯與約束定義。 要為 XML 文件撰寫結構,請使用該 WriteXmlSchema 方法。

XML 架構是依據 XSD 標準撰寫的。

若要將資料寫入 XML 文件,請使用以下 WriteXml 方法。

繼承自該System.Xml.XmlWriter類別的一個類別是 。XmlTextWriter

另請參閱

  • 使用 ADO.NET

適用於

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 結構以 XML 架構寫入指定的 Stream 物件。

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
Public Sub WriteXmlSchema (stream As Stream, multipleTargetConverter As Converter(Of Type, String))

參數

stream
Stream

一個 Stream 可以寫入的物件。

multipleTargetConverter
Converter<Type,String>

一位代表曾轉 Type 為繩索。

適用於

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 結構寫成指定的 XML 結構 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 可以寫入的物件。

multipleTargetConverter
Converter<Type,String>

一位代表曾轉 Type 為繩索。

適用於

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 結構寫成指定的 XML 結構 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 可以寫入的物件。

multipleTargetConverter
Converter<Type,String>

一位代表曾轉 Type 為繩索。

適用於