Click here to Skip to main content
16,005,038 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help Needed in C# Chess Game development Pin
usmanali1235-Jan-06 3:57
usmanali1235-Jan-06 3:57 
GeneralRe: Help Needed in C# Chess Game development Pin
albCode5-Jan-06 3:58
albCode5-Jan-06 3:58 
GeneralRe: Help Needed in C# Chess Game development Pin
usmanali1235-Jan-06 4:11
usmanali1235-Jan-06 4:11 
AnswerRe: Help Needed in C# Chess Game development Pin
J4amieC5-Jan-06 5:30
J4amieC5-Jan-06 5:30 
AnswerRe: Help Needed in C# Chess Game development Pin
microsoc5-Jan-06 23:01
microsoc5-Jan-06 23:01 
QuestionReading mail Pin
alok_2k35-Jan-06 2:08
alok_2k35-Jan-06 2:08 
AnswerRe: Reading mail Pin
mav.northwind5-Jan-06 3:12
mav.northwind5-Jan-06 3:12 
Questioncreat a xml with data appending on the other Pin
dhol5-Jan-06 1:46
dhol5-Jan-06 1:46 
Hi
I have did a program such that , i will have two text box name and age in my form..and a button named save. so that when the values entered r in the text box..a xml file is created with those data..
.
Now I can able to create one set of values…. Now what I need is that when again some other value is entered in the textbox. It should also be written in the xml file..but without deleting the other. I mean it should append on the other..

For example: first I entered first as john and 22 for name and age ..it will added in the xml file..now again if I enter charu and 23 as name and age..
Now xml should have john and 22 as well as charu and 23…

And also one more thing is that if I again enter John. It should give a message that it has already been entered. No values should be repeated again. Please help me to do this…..

The coding which I did is as follows.

In side the button click
//save Button
private void button1_Click(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\PlaygroMenu.xsd");
//create a new row
DataRow oValues;
oValues = dataSet.Tables[0].NewRow();
//enter the values
oValues[0] = txtName.Text;
oValues[1] = Convert.ToInt32(txtAage.Text);

//check for duplication
bool hasalready = false;
foreach(DataRow row in dataSet.Tables[0].Rows)
{
if(row.ItemArray[0].ToString().Equals(txtID.Text))
{
hasalready = true;
}
}
//
if(!hasalready)
{
//add the row to the dataset
dataSet.Tables[0].Rows.Add(oValues);
//write the data to a xml file
dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema);
MessageBox.Show("Saved");
}

else
{
MessageBox.Show("Already Exists");
}

}


private void Form1_Load(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\Menu.xsd");

System.IO.FileInfo file = new System.IO.FileInfo("..\\..\\mydata.xml");

//check whethere there is result xml file...
if (file.Exists)
{
dataSet.ReadXml("..\\..\\resultdata.xml");
}

}


Please help me to do this..

Dhol





Questionhow to submit a form based on a condition in C# Pin
Suman Singh5-Jan-06 1:45
professionalSuman Singh5-Jan-06 1:45 
AnswerRe: how to submit a form based on a condition in C# Pin
Guffa5-Jan-06 2:15
Guffa5-Jan-06 2:15 
GeneralRe: how to submit a form based on a condition in C# Pin
Suman Singh5-Jan-06 2:24
professionalSuman Singh5-Jan-06 2:24 
AnswerRe: how to submit a form based on a condition in C# Pin
Guffa5-Jan-06 3:34
Guffa5-Jan-06 3:34 
QuestionCoding on the Vector Graphics Pin
richarding5-Jan-06 1:38
richarding5-Jan-06 1:38 
AnswerRe: Coding on the Vector Graphics Pin
mav.northwind5-Jan-06 3:15
mav.northwind5-Jan-06 3:15 
QuestionDoes File.Copy() prevent other file commands? Pin
Sensei765-Jan-06 1:24
Sensei765-Jan-06 1:24 
AnswerRe: Does File.Copy() prevent other file commands? Pin
S. Senthil Kumar5-Jan-06 3:19
S. Senthil Kumar5-Jan-06 3:19 
AnswerRe: Does File.Copy() prevent other file commands? Pin
mav.northwind5-Jan-06 3:19
mav.northwind5-Jan-06 3:19 
GeneralRe: Does File.Copy() prevent other file commands? Pin
Sensei765-Jan-06 5:30
Sensei765-Jan-06 5:30 
QuestionHow to put data from an IList to a Dataset Pin
LongNguyen5-Jan-06 0:34
LongNguyen5-Jan-06 0:34 
AnswerRe: How to put data from an IList to a Dataset Pin
VenkataRamana.Gali5-Jan-06 0:45
VenkataRamana.Gali5-Jan-06 0:45 
QuestionRe: How to put data from an IList to a Dataset Pin
LongNguyen5-Jan-06 0:49
LongNguyen5-Jan-06 0:49 
AnswerRe: How to put data from an IList to a Dataset Pin
VenkataRamana.Gali5-Jan-06 0:57
VenkataRamana.Gali5-Jan-06 0:57 
QuestionRe: How to put data from an IList to a Dataset Pin
LongNguyen5-Jan-06 14:57
LongNguyen5-Jan-06 14:57 
QuestionProblem after creating an installer for my project Pin
ger_creal4-Jan-06 23:57
ger_creal4-Jan-06 23:57 
AnswerRe: Problem after creating an installer for my project Pin
Curtis Schlak.5-Jan-06 8:23
Curtis Schlak.5-Jan-06 8:23 

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.