Home All Groups Group Topic Archive Search About

How to updata a datarow in a DataTable

Author
13 Nov 2005 2:17 PM
ad
I have a DataTable like

StID    SchoolYear Score
----------------------------------
1            2003        95
1             2004        96
2            2005        97

I want to update the DataRow of (1,2004,96) to  (1,2004,80)

How can I do?

Author
13 Nov 2005 5:00 PM
Scott M.
dataTable.Rows(1).item("Score") = 80


Show quote
"ad" <fly***@wfes.tcc.edu.tw> wrote in message
news:uJjQOzF6FHA.2816@tk2msftngp13.phx.gbl...
>I have a DataTable like
>
> StID    SchoolYear Score
> ----------------------------------
> 1            2003        95
> 1             2004        96
> 2            2005        97
>
> I want to update the DataRow of (1,2004,96) to  (1,2004,80)
>
> How can I do?
>
Author
13 Nov 2005 7:56 PM
Miha Markic [MVP C#]
1. Find proper row - you might do a foreach loop or use Select or something
similar
2. row["Score"] = 80;

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"ad" <fly***@wfes.tcc.edu.tw> wrote in message
news:uJjQOzF6FHA.2816@tk2msftngp13.phx.gbl...
>I have a DataTable like
>
> StID    SchoolYear Score
> ----------------------------------
> 1            2003        95
> 1             2004        96
> 2            2005        97
>
> I want to update the DataRow of (1,2004,96) to  (1,2004,80)
>
> How can I do?
>
Author
13 Nov 2005 8:31 PM
Scott M.
Note:  The Item property is the default property of a DataRow so:

[C#]

row["Score"] = 80;
and
row.item["Score"] = 80;

are the same thing and:

[VB.NET]

row("Score") = 80
row.Item("Score") = 80

are the same thing.

Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:e9$CexI6FHA.3616@TK2MSFTNGP10.phx.gbl...
> 1. Find proper row - you might do a foreach loop or use Select or
> something similar
> 2. row["Score"] = 80;
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "ad" <fly***@wfes.tcc.edu.tw> wrote in message
> news:uJjQOzF6FHA.2816@tk2msftngp13.phx.gbl...
>>I have a DataTable like
>>
>> StID    SchoolYear Score
>> ----------------------------------
>> 1            2003        95
>> 1             2004        96
>> 2            2005        97
>>
>> I want to update the DataRow of (1,2004,96) to  (1,2004,80)
>>
>> How can I do?
>>
>
>

AddThis Social Bookmark Button