|
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 quoteHide 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 quoteHide 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 quoteHide 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? >> > >
Other interesting topics
Add New in Bindings Navigator problem
ORM Frameworks for Visual Studio 2005 Inserting Access Table from VB.Net getting Identity value back Getting Identity back DataGridView Update Subprocedure for Oracle's SET DEFINE OFF command Fill data in Excel table Adding external data into database data before it is sent to Control (Repeater, Datagrid, etc.) Copy data from one database to another |
|||||||||||||||||||||||