GuestBook Using XML Database in ASP.Net
This Article will explain you how to create XML Database and how it is used in ASP.Net website as GuestBook or else.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: GuestBook Using XML Database in ASP.Net


nishana sirajPosted Jun 25, 2010, 3:39 AM EDT
hi freind , i have tried this in c# ,but it is adding only one record to the xml file,not able to append another one ,here is my code... public partial class userdetails2 : System.Web.UI.Page { DataSet ds = new DataSet(); DataTable dt = new DataTable(); string strFilePath = "c:\\guest.xml"; protected void Page_Load(object sender, EventArgs e) { initialisexmlfile(); } public void initialisexmlfile() { dt = ds.Tables.Add("myguest"); DataColumn dc = new DataColumn(); DataColumn[] arr = new DataColumn[1]; dc = dt.Columns.Add("id", typeof(System.Int32)); dc.AutoIncrement = true; dc.AutoIncrementSeed = 1; dc.AutoIncrementStep = 1; arr[0] = dc; dt.PrimaryKey = arr; dt.Columns.Add("datetime",typeof(System.DateTime)); dt.Columns.Add("name", typeof(System.String)); dt.Columns.Add("email", typeof(System.String)); dt.Columns.Add("comments", typeof(System.String)); ds.WriteXml(strFilePath, XmlWriteMode.WriteSchema); // ds.WriteXml("guestbook.xml", XmlWriteMode.WriteSchema); } public void displaydata() { DataView dw = ds.Tables[0].DefaultView; Repeater1.DataSource = dw; Repeater1.DataBind(); } public void populatedataset() { ds.ReadXml(strFilePath, XmlReadMode.IgnoreSchema); } protected void btnSubmit_Click(object sender, EventArgs e) { populatedataset(); DataRow row = ds.Tables[0].NewRow(); row["datetime"] = DateTime.Now ; row["name"] = txtEmail.Text.ToString(); row["email"] = txtName.Text.ToString(); row["comments"] = txtComments.Text.ToString(); ds.Tables[0].Rows.Add(row); DataRow row1 = ds.Tables[0].NewRow(); ds.WriteXml(strFilePath, XmlWriteMode.IgnoreSchema); displaydata(); } } thanks...