using DataTable.Select()
来源:互联网 发布:java怎么实现加法 编辑:程序博客网 时间:2024/06/05 08:14
private static void GetRowsByFilter()
{
DataTable customerTable = new DataTable( "Customers" );
// Add columns
customerTable.Columns.Add( "id", typeof(int) );
customerTable.Columns.Add( "name", typeof(string) );
// Set PrimaryKey
customerTable.Columns[ "id" ].Unique = true;
customerTable.PrimaryKey = new DataColumn[] { customerTable.Columns["id"] };
// Add ten rows
for( int id=1; id<=10; id++ )
{
customerTable.Rows.Add(
new object[] { id, string.Format("customer{0}", id) } );
}
customerTable.AcceptChanges();
// Add another ten rows
for( int id=11; id<=20; id++ )
{
customerTable.Rows.Add(
new object[] { id, string.Format("customer{0}", id) } );
}
string strExpr;
string strSort;
strExpr = "id > 5";
// Sort descending by column named CompanyName.
strSort = "name DESC";
// Use the Select method to find all rows matching the filter.
DataRow[] foundRows =
customerTable.Select( strExpr, strSort, DataViewRowState.Added );
PrintRows( foundRows, "filtered rows" );
foundRows = customerTable.Select();
PrintRows( foundRows, "all rows" );
}
private static void PrintRows( DataRow[] rows, string label )
{
Console.WriteLine( "/n{0}", label );
if( rows.Length <= 0 )
{
Console.WriteLine( "no rows found" );
return;
}
foreach( DataRow r in rows )
{
foreach( DataColumn c in r.Table.Columns )
{
Console.Write( "/t {0}", r[c] );
}
Console.WriteLine();
}
}
- using DataTable.Select()
- DataTable.Select
- datatable.select()
- DataTable Select
- DataTable.Select 方法 ()
- DataTable.Select 方法 (String)
- datatable select 性能
- Select DISTINCT on DataTable
- datatable的select用法
- datatable select 使用方法
- DataTable的Select事件
- DataTable.Select()使用心得
- DataTable.Select 方法
- DataTable.Select方法
- C# DataTable Select 用法
- DataTable.Select()注意事项
- dataTable.Select使用方法
- DataTable的Select方法
- FlyakiteOSX--一个好玩儿的东西
- 一句话MDI
- Ado属性
- 轻松一下,搞笑图片,小心笑死你
- 整理后的有关《新概念》英语的学习方法
- using DataTable.Select()
- Asp.net页面的生命周期
- 尽量放轻松些吧
- What Is Ruby on Rails
- RIP路由协议快速入门
- 为Windows应用创建简单的异步调用模式
- QoS
- 新手谈对象内存布局与内存对齐
- 根據datagrid模板列中的checkbox填入日期至textbox有解嗎?10/17