471,627 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Changing data in a dataset

I am trying to change a value in a Dataset but it doesn't work.

is there anything wrong with this code?

dataset.Tables[0].Rows[0].BeginEdit();
dataset.Tables[0].Rows[0].ItemArray[3] = "new Text";
dataset.Tables[0].Rows[0].EndEdit();

I have placed a breakpoint below those three lines, and when I debug the
application I can see that the value of
dataset.Tables[0].Rows[0].ItemArray[3] is not "new Text" but still the
old value.

Is there anything I could have forgotten?

Thanks
Ferdinand
Dec 7 '05 #1
1 1976
Ferdinand,

You don't need to call BeginEdit and EndEdit.

The reason that you do not see the changes taking place is that
ItemArray returns a NEW object array with a copy of the values in the row.
You can just set the value directly, like so:

dataset.Tables[0].Rows[0][3] = "new Text";

And then the change will be reflected.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ferdinand Zaubzer" <fe***************@schendl.at> wrote in message
news:Ol****************@tk2msftngp13.phx.gbl...
I am trying to change a value in a Dataset but it doesn't work.

is there anything wrong with this code?

dataset.Tables[0].Rows[0].BeginEdit();
dataset.Tables[0].Rows[0].ItemArray[3] = "new Text";
dataset.Tables[0].Rows[0].EndEdit();

I have placed a breakpoint below those three lines, and when I debug the
application I can see that the value of
dataset.Tables[0].Rows[0].ItemArray[3] is not "new Text" but still the old
value.

Is there anything I could have forgotten?

Thanks
Ferdinand

Dec 7 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by G-Fit | last post: by
2 posts views Thread by John Smith | last post: by
3 posts views Thread by Doug | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.