Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 10th, 2006, 07:27 PM
ck ck is offline
Authorized User
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent ! Please Help...

hi, i am a beginner, do anyone how to store data into XML database using MS Visual C#.NET ??? example of my XML:


in my web interface, i got a button called "save", a textbox called "txtName", & a dropdownlist/combo box called "cboGender". so, after i enter (data) in all fields that i mentioned above(txtName, cboGender), then click the "save" button, it will store/save all the data that i enter into the XML database. in this program, it can't allow to use SQL connnection. i hope any expert can help me on this. below is my c# code:

private void cmdSave_Click(object sender, System.EventArgs e)
   DataSet ds = new DataSet();
   string filepath = @"C:\Documents and Settings\All
   FileStream findata = new FileStream
   ds.Tables["Enrolment"].Columns["FirstName"] = txtfname.Text;

P/s: i also dunno how to get the dropdownlist/combo box data & save it into XML database, because textbox property is .text, but combo box there are no .text.

i will appreciate if someone can help me....thanks a lot...


Old July 4th, 2006, 03:24 AM
Registered User
Join Date: Jul 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

You can use SelectedValue or SelectedItem.Text or SelectedItem.Value of dropdownlist i think this will help you.

Old September 29th, 2006, 03:38 AM
Registered User
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to little.witch

Generally you could create a XML Schema of your XML database/dataset:
You could either create it by adding a new XML Schema (*.xsd) item to you project from the VS and create your database definition by the drag-n-frop methos or create a DataSet object which to write down its own schema for you:
DataSet ds = new DataSet();
            DataTable dt = new DataTable("TableName");
            dt.Columns.Add(new DataColumn("name"));
//in the same manner add the other columns you have
            ds.Tables.Add(dt);//add the table to the dataset
            ds.WriteXmlSchema(@"schema path");//make the dataset write the schema for you - n.b.: uses full path

when you want to load the schema to another dataset just do:
ds.ReadSchema(@"schema path");
//and you have all your tables loaded

From this point on you can fill the data:
DataRow dr = ds.Tables[0].NewRow();//0 is the index of the table in the DataSet
//in the same manner fill other cells
//when you have finished with filling the cells:
ds.Tables[0].Rows.Add(dr);//0 is the index of the table in the DataSet

When you are ready with the adding of the rows:

ds.WriteXml(@"xml data file full path");

When you want to load the above written data to a nwe dataset:

ds.ReadXml(@"xml data file full path");

NJoy! :)

If you know the enemy
and know yourself, you
need not fear the result
of a hundred battles.If
you know yourself but not
the enemy,for every
victory gained you will
also suffer a defeat.
If you know neither the
enemy nor yourself, you
will succumb in every battle.


Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent deb_kareng ASP.NET 2.0 Professional 1 August 13th, 2007 07:29 AM
it's urgent deb_kareng ASP.NET 2.0 Professional 3 August 7th, 2007 07:40 AM
urgent help yash_coolbuddy_forindia BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 May 7th, 2007 08:40 AM
urgent???????????? nsr35 Beginning VB 6 1 October 3rd, 2005 10:57 AM
urgent ??????????????? nsr35 Pro VB Databases 0 October 3rd, 2005 04:53 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.