Groups | Blog | Home
all groups > dotnet compact framework > may 2007 >

dotnet compact framework : Value in DataTable not changing when new value assigned


John Dinning
5/12/2007 12:00:00 AM
VS2005, C#, Win CE 5.

I have a very strange problem which must have a simple answer. I am new to
..NET.

I am reading a simple XML file into a DataSet (1 table, 5 rows, 2 string
fields per row).
This works ok, I can see the data in the debugger QuickWatch window.

I want to change the value of a string field in the DataSet table currently
set to "123":

MyDataTable.Rows[2].ItemArray[1] = "xyz"

It does not change! It is still "123" immediately after this line and no
exception.
The RowState before and after this line is "Unchanged"

How can this be?
The DataSet is not read only (and I assume if it was, then an exception
would be generated when trying to change the value).

Any help extremely welcome.

John.

John Dinning
5/12/2007 12:00:00 AM
Thanks for the quick response but the computer says:

'System.Data.DataRow' does not contain a definition for 'Item'

John.

[quoted text, click to view]
Instead of ItemArray, use Item property -->

MyDataTable.Rows[2].Item[1] = "xyz"




On 12 Mayýs, 11:59, "John Dinning" <j...@NOSPAMbarcodelogic.com.au>
[quoted text, click to view]


kenanmengu NO[at]SPAM hotmail.com
5/12/2007 2:18:40 AM
Instead of ItemArray, use Item property -->

MyDataTable.Rows[2].Item[1] =3D "xyz"




On 12 May=FDs, 11:59, "John Dinning" <j...@NOSPAMbarcodelogic.com.au>
[quoted text, click to view]

John Dinning
5/13/2007 12:00:00 AM
Problem solved. The tidier way to do it:

DataRow["ColName"] = "xyz";

Works fine. I can't say I understand why the other method doesn't.
Learners beware of copying code snippets off the net and assuming they have
been debugged!

John.


[quoted text, click to view]

AddThis Social Bookmark Button