简体   繁体   English

如何使用C#更新数据集中的单元格

[英]How to update a cell in dataset using C#

I need to check from a dataset if the value NOT COMPLETED exist under the column status then if it does, replace NOT COMPLETED with COMPLETED . 我需要从一个数据集来检查值NOT COMPLETED的列状态下存在,那么如果是,请更换NOT COMPLETEDCOMPLETED I am using dataset and data adapter in C#. 我在C#中使用数据集和数据适配器。 This is what I have done so far. 到目前为止,这是我所做的。 Your help will be very appreciated. 非常感谢您的帮助。 Thank you in advance 先感谢您

public void check()
{
    DataRow[] cs;

    //search for value of "NOT COMPLETED" in the "case" table in the dataset   
    cs = ds2.Tables["News"].Select("status = 'NOT COMPLETED'");
}

To get all rows, where the status is set to 'NOT COMPLETED' you can take a look at this code: 要获取状态为“ NOT COMPLETED”的所有行,可以查看以下代码:

const string news = "news";
const string status = "status";
const string notCompleted = "'NOT COMPLETED'";

DataSet ds = new DataSet();
ds.Tables.Add(news);
ds.Tables[news].Columns.Add(status);
ds.Tables[news].Rows.Add("test");
ds.Tables[news].Rows.Add(notCompleted);
ds.Tables[news].Rows.Add("dummy");
IEnumerable<DataRow> dataRows = ds.Tables[news].Rows.Cast<DataRow>().Where(row => row[status].ToString() == notCompleted);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM