• 쇼핑몰
  • 커뮤니티
  • 북마크

vb.net




[Controls] [vb.net] DataTable 내용을 XML로 저장 및 불러오기

하나를하더라도최선을
2020.09.14 00:01 86 0

본문



Example 1:)
    Write:
        dt1.TableName = "MyDataTable"
        dt1.WriteXmlSchema(Application.StartupPath + "\test_sh.xml", True)
        dt1.WriteXml(Application.StartupPath + "\test_dt.xml", True)
    Read:
        dt2 = New DataTable
        dt2.ReadXmlSchema(Application.StartupPath + "\test_sh.xml")
        dt2.ReadXml(Application.StartupPath + "\test_dt.xml")
Example 2:)
    Write:
        Dim writer As System.IO.StringWriter = New System.IO.StringWriter()
        customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, False)
    Write:
        writer = New System.IO.StringWriter()
        customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, True)
Example 3:)
    Write:
        Dim xmlStream As System.IO.MemoryStream = New System.IO.MemoryStream()
        table.WriteXml(xmlStream, XmlWriteMode.WriteSchema)
        xmlStream.Position = 0
    Read:
        Dim newTable As DataTable = New DataTable()
        newTable.ReadXml(xmlStream)
Example 4:)
    Write:
        Dim fileName As String = "C:\TestData.xml"
        table.WriteXml(fileName, XmlWriteMode.WriteSchema)
    Read:
        Dim newTable As DataTable = New DataTable()
        newTable.ReadXml(fileName)
 




댓글목록 0

등록된 댓글이 없습니다.