Click here to Skip to main content
13,351,896 members (87,759 online)
Click here to Skip to main content
Add your own
alternative version


45 bookmarked
Posted 22 Dec 2002

NoteBook using XML and ADO.NET

, 22 Dec 2002
Rate this:
Please Sign up or sign in to vote.
An article on using XML and ADO.NET to create an appointment/address book.
<!-- Download Links --> <!-- Article image -->

Sample Image - xml_notebook.jpg


This code is to demonstrate how to use xml file as a database. It uses ADO.NET to access data inside the xml file. Also it uses xml schema to determine the data that will be loaded to the dataset.

The code uses these technologies to develop a Notebook. This notebook consists of two things. First thing is an Addresses keeper; the user can save information about other people on it. The second part of the Notebook is the Appointments part; the user can store all his important appointments or dates.


This project is using XML (*.xml) as a database to hold the data and XML Schema (*.xsd) to control the contents of the database. XML Schema is also used to control the contents of the dataset, because there are data that shouldn't be loaded from the XML file to the dataset then we can restrict these data by assigning an XML Schema to the dataset then load the contents of the xml file. Only the designated data in the XML Schema will be loaded to the dataset object.

The data set will change the order of the data and it will make them in tables instead of what they were. This will make accessing them easier. If there is an XML field that may appear more than one time (multi value field) example :


Here in this part of the XML file when loaded to the dataset it will create two tables, first table is named TableName and it will contains one column that is linked to the second table, the second table will be created because the <field> tag appears more than one time under the same table so the dataset will create a table called field with two columns first column is field_Colum and the second column is a link to the first table. The links in the first and second table will contains the same key.

The data set will create the tables according to the design in the XML Schema. In the XML Schema it is possible to determine the number of occurrence for a field.

To understand the code you should first see the schema files that are within the project.

Using the code

The code is documented with the XML Documentation and so it is easy to create documentation from the comments. Also I did comments on each step of the code to show what it does. I am sure you will find reading the code easy.

This project consists of three types of files; the first type is the XML file. It is only one file and it holds the database. This file must exist in the project even if it is empty, its name is "AllTables.xml".

The second group is the XML Schema, they are three files. The first file is "1AllTables.xml" it controls the contents of the XML file. The second file is "AddressBookTables.xsd", it determine the tables that are related to the Address Book. This file is loaded to the dataset before loading the XML file when we need only information about addresses. The third file is "AppointmentTable.xsd" and it is similar to the second file.

The third group of files is the C# files, there are 6 files. Five of these six files are related to the forms and their functionalities and one file with the name "NBDatabase.cs" is a class that handles all functions that are related to the database.

I will show you part of the code that relates to loading the xml file and the dataset. The order is important in this code.

// create an object to hold the contents of the xml file
xmlDoc = new XmlDataDocument();

// creating an object to hold the dataset
ds = xmlDoc.DataSet;

// loading the schema to the dataset.
// in order to make holding only the data related to the schema

// loading all tables to the xmlDoc
// and only tables in the schema to the ds


This project demonstrates how to use an XML file as database with ADO.NET. This project is a Note Book that enables the user to store information and retrieve them. XML is not good as a complete database, especially if the data sets are huge. XML is useful, regarding to a database, making it a middle tier between the database and the application. When the application is started then all needed data are brought from the database to the xml file and the connection with the database is closed. When the application finishes all changed to the XML file are applied to the database. This project shows how to deal with the XML file.

About the Project

I built this project for my doctor, Dr. Paul D. Manuel.

About the Author

A Computer Science student at King Fhad University of Petrolume & Minerals in Saudi Arabia. Have background about lot of programming languages and expert in PHP language.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralSome tips/questions Pin
leppie24-Dec-02 12:20
memberleppie24-Dec-02 12:20 
GeneralRe: Some tips/questions Pin
s972687(KFUPM)25-Dec-02 0:58
members972687(KFUPM)25-Dec-02 0:58 
GeneralRe: Some tips/questions Pin
leppie25-Dec-02 8:08
memberleppie25-Dec-02 8:08 
GeneralRe: Some tips/questions Pin
s972687(KFUPM)26-Dec-02 9:15
members972687(KFUPM)26-Dec-02 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 23 Dec 2002
Article Copyright 2002 by s972687(KFUPM)
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid