4.02.2008

Get the distinct data from System.Data.DataTable

Here is a great KB that tell u how to get the distinct data from DataTable.

For example, if we have a column "product" include different value inside the data table, usually, we can get the distinct data from foreach loop to get info. that's a common situation. Now, we have this helper class, we can just call it and get the data we want.

這裡是一個很棒的KB, 他教我們怎咪從DataTable撈Distinct的資料出來.

舉例來說, 假設我們的DataTable裡面有一個欄位是"產品", 每一列(row)都存了名稱, 會有重覆. 如果我們要產品列表, 要就組成DataSet用SQL撈,要不就是Foreach去撈. 這個狀況是很常見的. 所以我們如果在我們的工具箱內加上這個helper class, 那以後我們只要呼叫之後就可以取用了. 真好!!!

No comments: