如何更新表格中的数据? [英] How do i update data in a table?

查看:119
本文介绍了如何更新表格中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新数据库中的某个字段,但是当我尝试更新该数据行0时,尽管我正在尝试更新其他数据行,例如datarow 5,但我认为问题代码是; DataRow datarow =数据集.Tables["Objects"].Rows [0]; 

I am trying to update a certain field in a database, but when i try this datarow 0 is always updated, eventhough i am trying to update a different datarow, such as datarow 5. I think the problem code is  DataRow datarow = dataset.Tables["Objects"].Rows[0]; 

请让我知道我是否错过了任何事情.

Please let me know if i have missed anything.

谢谢



推荐答案

例如,您要更新名称为"ColumnX"的列,在dataTable(属于DaraSet的一部分)中,您可以执行以下操作:

For example you want to update column with the name "ColumnX" in the dataTable (which is part of the DaraSet) you do:


DataSet.Tables["MyTableName"].Rows[X]["ColumnX"] = "MyNewValue";

//MyTableName is your table name (in dataSet)
//X is a row index
//"ColumnX" is name of the column you want to update!


这篇关于如何更新表格中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆