有一个用户表userInfo
和一个DataTable保存的是userInfo里的所有用户信息
一些简单的可以在DataTable里进行的查询,可以避免多次访问数据库.

1.查询userInfo里最小的年龄
SQL: select min(age) from userInfo
DT  : dt.Compute("min(age)""");

2.查询年龄22岁的人员
SQL: select * from userInfo where age = '22'
DT  : dt.Select("age= '22'");

3.DataTable排序
GridViewSortExpression = "age";
GridViewSortDirection = "DESC";
DataView dataView = new DataView(dt);
dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection);
                   


相关文章:

  • 2021-08-20
  • 2021-12-30
  • 2021-07-02
  • 2021-11-05
  • 2022-12-23
  • 2022-02-20
  • 2021-11-08
  • 2021-10-12
猜你喜欢
  • 2021-06-12
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
相关资源
相似解决方案