|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to updata a datarow in a DataTableI 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? 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? > 1. Find proper row - you might do a foreach loop or use Select or something
similar 2. row["Score"] = 80; -- Show quoteMiha 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? > 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? >> > > |
|||||||||||||||||||||||