[問題] datatable select 用法

看板C_Sharp作者時間16年前 (2009/06/25 11:01), 編輯推噓1(103)
留言4則, 2人參與, 最新討論串2/2 (看更多)
欄位 0 1 2 3 4 result a c t g t true c a t a q false 昨天講的不清楚 我想要的是 欄位是定義datatable 的column 名稱 下面的是row輸入的資料 我定義 column是這樣定義的 for (int i = 0; i < 4; i++) { DataColumn column = new DataColumn(i.ToString()); column.DataType = typeof(string); samples.Columns.Add(column); } DataColumn column1 = new DataColumn("result"); column1.DataType = typeof(bool); samples.Columns.Add(column1); 我想要將samples裡面select 欄位 4 內容是 t 的東西 我是這樣寫的 DataRow[] rows = samples.Select("'4' = 'a'"); 但是這樣他沒有把我想要的ROW輸出出來 是我有寫錯嗎 這樣COMPILE是可以過 但是 DataRow[] rows = samples.Select("result" + " = true"); 這樣寫就會有ROW出來 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.121.197.106

06/22 22:04, , 1F
哇,我還是第一次看到這樣用,幫不了你
06/22 22:04, 1F

06/22 22:05, , 2F
試試samples.Select("4" + " = a");
06/22 22:05, 2F

06/22 22:25, , 3F
若要形成filterExpression引數,請使用與建立DataColumn類別的
06/22 22:25, 3F

06/22 22:25, , 4F
Expression 屬性值的相同規則
06/22 22:25, 4F
文章代碼(AID): #1AGkY000 (C_Sharp)
文章代碼(AID): #1AGkY000 (C_Sharp)