2013-05-02 70 views
0

我需要從數據集中檢查值列NOT COMPLETED是否存在於列狀態下,如果是,請將NOT COMPLETED替換爲COMPLETED。我在C#中使用數據集和數據適配器。這是我迄今爲止所做的。您的幫助將非常感激。謝謝你在前進如何使用C#更新數據集中的單元格

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'"); 
} 
+2

我想,在技術上你不能指責他沒有做任何事情,但這很接近它。也許多一點時間谷歌可能會產生一些您可以使用的示例代碼。 – DeanOC 2013-05-02 04:25:43

+0

歡迎來到[so]。我在這裏沒有看到問題,最新的問題是什麼? – 2013-05-02 04:27:07

+0

如何尋找和學習?我看不出你想要做什麼。詢問前請嘗試顯示嘗試的代碼。 – 2013-05-02 04:30:01

回答

0

要獲得所有行,其中的狀態設置爲「未完成」,你可以看看下面的代碼:

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

謝謝你Tomtom爲您的回覆 – user2341596 2013-05-13 01:27:22

+0

如何在您的示例中使用「LIKE」或「CONTAINS」代替「==」 – user2341596 2013-06-05 18:53:26

+0

只需將==替換爲.Contains(not Completed) – Tomtom 2013-06-05 19:41:21

相關問題