Convert Access data to XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Parasyke

    #1

    Convert Access data to XML

    Thanks in advance. I'm new to XML. I need to convert an existing Access
    table into XML which will allow me on a form to read the table into
    XML, edit, then reconvert it back to the Access table. I have
    successfully added the Northwind database to my data sources in Visual
    Studio 2003 (Standard Edition). I also have the following code which
    reads from an EXISTING XML file not related to the Access file. How
    could I alter it to pull from Access? Below is the read and Write SUBS
    for the existing XML:


    Private Sub btnLoadXml_Clic k(ByVal sender As System.Object, ByVal e
    As System.EventArg s) Handles btnLoadXml.Clic k
    Dim xtr As XmlTextReader = _
    New XmlTextReader(" C:\Documents and Settings\dcampb e\My
    Documents\Visua l Studio 2005\Projects\3 10C02\310C02\Bo oks.xml")
    xdd = New XmlDataDocument ()
    ds = xdd.DataSet()
    ds.ReadXmlSchem a(xtr)
    xtr.Close()
    xtr = New XmlTextReader(" C:\Documents and Settings\dcampb e\My
    Documents\Visua l Studio 2005\Projects\3 10C02\310C02\Bo oks.xml")
    xtr.WhitespaceH andling = WhitespaceHandl ing.None
    xdd.Load(xtr)
    dgXML.DataSourc e = ds
    dgXML.DataMembe r = "Book"
    xtr.Close()
    End Sub


    Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles btnSave.Click
    Dim xtw As XmlTextWriter = New XmlTextWriter(" C:\Documents and
    Settings\dcampb e\My Documents\Visua l Studio
    2005\Projects\3 10C02\310C02\Bo oks.xml", System.Text.Enc oding.UTF8)
    xtw.Formatting = Formatting.Inde nted
    xdd.WriteTo(xtw )
    'Clean up
    xtw.Close()
    MessageBox.Show ("The XML file has been successfully updated !")



    End Sub

  • GhostInAK

    #2
    Re: Convert Access data to XML

    Hello Parasyke,

    You could...
    Create a DataSet
    Create a DataTable in the DataSet
    Fill the DataTable with data from the Access DB
    Serialize the DataSet to disk or memory for editing

    Then to round-trip it..
    Deserialize the XML doc back into a DataSet
    Update the Access DB from the DataSet

    -Boo


    Comment

    Working...