Results 1 to 3 of 3

Thread: [resolved] updating an xml dataset - not working?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    280

    [resolved] updating an xml dataset - not working?

    hi,

    I have an app i wrote, it involves a list of data that is sourced from an xml structure - its horrible for the user to use as the list keeps reordering while they use it - this is down to the way i have coded it!!

    I have problems updating a .net dataset - I cannot updata fields within and have to delete the whole line and re-add it with a new one - seems hardwork just to update a field value!

    eg

    VB Code:
    1. DataRow obj_newrow  = cur_dataset.Tables["configset"].NewRow();
    2. obj_newrow[0]  = cur_dataset.Tables["configset"].Rows[int_tab_count].ItemArray[0].ToString();
    3.  
    4. cur_dataset.Tables["configset"].Rows.InsertAt(obj_newrow,int_tab_count);
    5. cur_dataset.Tables["configset"].Rows.RemoveAt((int_tab_count+1));

    I cannot see why this is - I cannot make the following demo code work - the "after" message returns "fieldvalue1"




    VB Code:
    1. test.xml =
    2.  
    3. <?xml version="1.0" standalone="yes"?>
    4. <testxml>
    5.   <configset>
    6.     <field1>fieldvalue1</field1>
    7.     <field2>fieldvalue2</field2>
    8.     <field3>fieldvalue2</field3>
    9.   </configset>
    10. </testxml>
    11.  
    12.  
    13. ---
    14.  
    15. System.Data.DataSet cur_dataset = new DataSet();
    16. cur_dataset.ReadXml("C:\\test.xml");
    17.  
    18. MessageBox.Show("before=" + cur_dataset.Tables["configset"].Rows[0].ItemArray[0].ToString());
    19.  
    20. cur_dataset.Tables["configset"].Rows[0].ItemArray[0] = "newvalue";
    21.  
    22. MessageBox.Show("after=" + cur_dataset.Tables["configset"].Rows[0].ItemArray[0].ToString());

    I have also tried adding:-

    VB Code:
    1. cur_dataset.Tables["configset"].Rows[0].AcceptChanges();
    2. cur_dataset.Tables["configset"].AcceptChanges();
    3. cur_dataset.AcceptChanges();

    I cannot get set row0, field0 to "newvalue" other than copying the whole record into a new datarow and doing the insertatr/removeat

    is this correct or am i doing something wrong,

    many thanks for any comments,
    cheers AJP

    ps - ms's site seems to say this is do-able - see http://msdn.microsoft.com/library/de...sindataset.asp
    Last edited by jpritchard; Dec 13th, 2005 at 04:33 AM. Reason: [resolved]
    Intel 486dx3 - VB4 - DR-Dos - 2mb EdoRam - 2x CDrom drive - Window for Workgroups - CGA monitor

    Real programmers use less....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width