方法1: SqlDataAdapter的分页
string temp_sqlstr = "select * from testDataServer ";
SqlDataAdapter adapter = new SqlDataAdapter(temp_sqlstr, pubFunction.P_strConn);
DataSet ds1 = new DataSet();
long datestart = DateTime.Now.Ticks;
Response.Write( "datestart " + datestart.ToString() + " <br> ");
adapter.Fill(ds1, 9990, 10, "0 ");
long dateEnd = DateTime.Now.Ticks;
long dIn = dateEnd - datestart;
Response.Write( "dateEnd " + dateEnd.ToString());
Response.Write( " <br> " + dIn.ToString() + " <br> ");
Response.Write( "打印数据: ");
for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
{
Response.Write( " <br> " + ds1.Tables[0].Rows[j][0].ToString());
}
方法2: 网上比较号称比较高效的分页过程
存储过程:
CREATE PROCEDURE litao_GetRecordByPage
@tblName varchar(255), -- 表名
@fldName varchar(255), -- 主键/排序 字段名
@PageSize int = 10, -- 页尺寸
@PageIndex int = 1, -- 页码
@IsReCount bit = 0, -- 返回记录总数, 非 0 值则返回
@OrderType bit = 0, -- 设置排序类型, 非 0 值则降序
@strWhere varchar(1000) = ' ' -- 查询条件 (注意: 不要加 where)
AS
declare @strSQL varchar(6000) -- 主语句