Click here to Skip to main content
15,885,365 members
Articles / Programming Languages / Visual Basic

Xml Database Demo

Rate me:
Please Sign up or sign in to vote.
4.59/5 (25 votes)
31 Jul 2008CPOL9 min read 150.2K   8K   110  
This article walks you through creating a simple windows database with an Xml file as it's datasource.
Public Class Form1

    Private mXmlFilePath As String = "c:\Temp\XmlDatabaseDemo.xml"

    Private Sub Form1_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

        'If the file exists, then read the data from the Xml file
        '  into the DataSet
        If My.Computer.FileSystem.FileExists(mXmlFilePath) = True Then _
            DsXmlDbDemo.ReadXml(mXmlFilePath)

    End Sub

    Private Sub CustomersBindingNavigatorSaveItem_Click( _
        ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles CustomersBindingNavigatorSaveItem.Click

        'Commit the Customer Data and the Orders Data to each
        '  respective DataTable.
        Me.Validate()
        CustomersBindingSource.EndEdit()
        OrdersBindingSource.EndEdit()

        'Write the data from the DataSet out to the Xml File.
        DsXmlDbDemo.WriteXml(mXmlFilePath)

    End Sub

    Private Sub OrdersDataGridView_Enter(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles OrdersDataGridView.Enter

        'Commit the Customer Data to the DataTable
        CustomersBindingSource.EndEdit()

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer DataPrint, LLC
United States United States

Comments and Discussions