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:
DataRow obj_newrow = cur_dataset.Tables["configset"].NewRow(); obj_newrow[0] = cur_dataset.Tables["configset"].Rows[int_tab_count].ItemArray[0].ToString(); cur_dataset.Tables["configset"].Rows.InsertAt(obj_newrow,int_tab_count); 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:
test.xml = <?xml version="1.0" standalone="yes"?> <testxml> <configset> <field1>fieldvalue1</field1> <field2>fieldvalue2</field2> <field3>fieldvalue2</field3> </configset> </testxml> --- System.Data.DataSet cur_dataset = new DataSet(); cur_dataset.ReadXml("C:\\test.xml"); MessageBox.Show("before=" + cur_dataset.Tables["configset"].Rows[0].ItemArray[0].ToString()); cur_dataset.Tables["configset"].Rows[0].ItemArray[0] = "newvalue"; MessageBox.Show("after=" + cur_dataset.Tables["configset"].Rows[0].ItemArray[0].ToString());
I have also tried adding:-
VB Code:
cur_dataset.Tables["configset"].Rows[0].AcceptChanges(); cur_dataset.Tables["configset"].AcceptChanges(); 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




Reply With Quote