简体   繁体   中英

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 . I am using dataset and data adapter in 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:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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