473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

example of Inserting and Retrieving data from xml file

This is an example of Inserting and Retrieving data from xml file.


Expand|Select|Wrap|Line Numbers
  1. private void Page_Load(object sender, System.EventArgs e)
  2.         {
  3.             // Put user code to initialize the page here
  4.  
  5.             if(!IsPostBack)
  6.             {
  7.                 BindGrid();
  8.             }
  9.         }
  10.  
  11.  
  12. private void BindGrid()
  13.         {
  14.             ds = new DataSet();
  15.             try
  16.             {
  17.                 ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  18.                 DataGrid1.DataSource = ds;
  19.                 DataGrid1.DataBind();
  20.             }
  21.             catch(Exception ex)
  22.             {
  23.                 throw ex;
  24.             }
  25.         }
  26.  
  27.  
  28.  
  29.  
  30.     private void Button1_Click(object sender, System.EventArgs e)
  31.         {
  32.             ds = new DataSet();
  33.             try
  34.             {
  35.                 ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  36.                 DataRow row = ds.Tables[0].NewRow();
  37.                 row["name"]=txtName.Text;
  38.                 row["fathersname"]=txtFName.Text;
  39.                 row["address"]=txtAddress.Text;
  40.                 ds.Tables[0].Rows.Add(row);
  41.                 ds.WriteXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  42.                 txtAddress.Text="";
  43.                 txtFName.Text="";
  44.                 txtName.Text ="";
  45.                 BindGrid();
  46.             }
  47.             catch(Exception ex)
  48.             {
  49.                 throw ex;
  50.             }
Sep 25 '07 #1
1 1596
RedSon
5,000 Expert 4TB
The account of member hanusoft has been banned for a period of one week. Cross posting, failure to use code tags and spamming your website are against site rules. Please read the posting guidelines.

-MODERATOR
Nov 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jaunty Edward | last post by:
Hi, My problem is a little advance I feel, please check it and guide me if you can. I have a lot of similar format text files, that has name in the first line then age in forth line second and...
2
by: tperovic | last post by:
Using SS2K, I'm getting the following error while bulk inserting: Column 'warranty_expiration_date' cannot be modified because it is a computed column. Here is my bulk insert statement: ...
0
by: Alistair | last post by:
Hi all, I am creating a database based site that keeps track of books, who has read them and the comments they have. After a little help in M.P.I.asp.DB I managed to create a database (access...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
0
by: kid4rilla | last post by:
I can successfully write the binary data to an image data type, and successfully retrieve it, but when I attempt to play the file in media player after retrieving it, I get the file type isn't...
2
by: Richard Maher | last post by:
Hi, Recently on the web I came across documentation discussing Data Source Objects (DSO) in relation to browser and html functionality (in particular the ability to declare a Java applet as a...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
1
by: hanusoft | last post by:
This is an example of Inserting and Retrieving data from xml file. private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here ...
2
by: cluce | last post by:
I am trying to read a csv file with user info (username, password, email, address, city, zip, state, etc.) I am inserting the username, password, email into the aspnet_memberhsip table using the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.