服務(wù)熱線
153 8323 9821
http://msdn.microsoft.com/zh-cn/library/way3dy9w%28VS.80%29.aspx
public DataRow[] Select (
string filterExpression,
string sort
)
參數(shù)
filterExpression
要用來(lái)篩選行的條件。
sort
一個(gè)字符串,它指定列和排序方向。
返回值
與篩選表達(dá)式相匹配的 DataRow 對(duì)象的數(shù)組。
備注
若要形成 filterExpression 參數(shù),請(qǐng)使用與創(chuàng)建 DataColumn 類的 Expression 屬性值相同的規(guī)則。Sort 參數(shù)也使用與創(chuàng)建類的 Expression 字符串相同的規(guī)則。
示例
private void GetRowsByFilter()
{
DataTable table = DataSet1.Tables["Orders"];
// Presuming the DataTable has a column named Date.
string expression = "Date > 1/1/00 ";
// Sort descending by column named CompanyName.
string sortOrder = "CompanyName DESC";
DataRow[] foundRows;
// Use the Select method to find all rows matching the filter.
foundRows = table.Select(expression, sortOrder);
// Print column 0 of each returned row.
for(int i = 0; i < foundRows.Length; i ++)
{
Console.WriteLine(foundRows[i][0]);
}
}
上一篇:cstr用法