Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. error: key already exists

error: key already exists

Scheduled Pinned Locked Moved C#
xmlcsharpdatabasedata-structureshelp
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dhol
    wrote on last edited by
    #1

    Hi i am working in c# with infragistics In c# windows applicaion, I will be passing data from textbox..such that for example:i haev 3 texboxes labeled name: age: salary:.... Now name is the parent and age and salary r the child..so if i pass data in the appropriate textbox..It should be added in the ultrawintree.......such that name(parent) should show up on the root node of the tree. and age and salary(child) should show up under the root node. I did this as follows.. //ultrawintree private Infragistics.Win.UltraWinTree.UltraTree ultraTree1; //form load private void Form1_Load(object sender, System.EventArgs e) { DataSet dataSet = new DataSet(); //read the schema dataSet.ReadXmlSchema("..\\..\\Menu.xsd");//menu.xsd contains name, age and salary dataSet.WriteXml("..\\..\\resultdata.xml",XmlWriteMode.WriteSchema); } //buttton click private void button1_Click(object sender, System.EventArgs e) { DataSet dataSet = new DataSet(); // Read the existing xml dataSet.ReadXml("..\\..\\resultdata.xml"); //name textbox----string type string strName = txtName.Text; //age text box----int type string strage = txtAge.Text; int intAge; if (!strAge.Equals(string.Empty)) // check to make sure the user entered something intAge = Convert.ToInt32(strAge); //Salary textbox------int type string strSalary = txtSalary.Text; int intSalary; if (!strSalary.Equals(string.Empty)) // check to make sure the user entered something intSalary = Convert.ToInt32(strSalary); //create a new row DataRow newrow; newrow = dataSet.Tables[0].NewRow(); // add new row. newrow["Name"] = strName; newrow["Age"] = strAge; newrow["Salary"] = strSalary; //add parent node in ultrawintree Infragistics.Win.UltraWinTree.UltraTreeNode anode = new Infragistics.Win.UltraWinTree.UltraTreeNode(); //add parent node anode.Text = txtName.Text; //add child nodes anode.Nodes.Add(txtAge.Text); anode.Nodes.Add(txtSalary.Text); anode.Expanded = true; ultraTree1.Nodes.Add(anode); //add the row to the dataset dataSet.Tables[0].Rows.Add(newrow); //write the data to a xml file dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema); dataSet.AcceptChanges(); MessageBox.Show("Saved"); } so now when i run this program, as it reads a xml schema and creates a xml file.. n

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups