//在数据访问的时候就分页
数据访问的分页排序方法
int pageId:当前页,
int pageSize每页数据数,
string addWhere查询条件,
string taxisName要排序的列名,
string descOrAsc:2种排序参数(desc/asc),
string tableName:数据表名
public static DataSet getDataSet(int pageId,int pageSize, string addWhere, string taxisName, string descOrAsc,string tableName)
{
string sql= "select * from (select ROW_NUMBER() OVER(ORDER BY " + taxisName + " " + descOrAsc + ") as pageId,* from "+tableName+") as tablename ";
sql += " where pageId>=" + (pageSize * (pageId - 1) + 1).ToString() + " and pageId<=" + (pageSize * pageId).ToString() + " " + addWhere;
return DbHelperSQL.Query(sql);
}//该方法sql语句有sql注入的漏洞,在用户输入条件上判断用户输入是否合法,防御sql注入 到baidu还是有很多资料的
参数都有了,应该会做了吧
要任何的分页和每页数据数,改变一下参数的值就可以了 |