多款高效sql存储过程分页代码(1/8)
public int PageCurrent = 1;
public int PageSize = 25;
public int RowsCount = 0;
string userid, username;
public DataTable dt = new DataTable();
public string path, userwelcome;
public string opt,cid;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Params["page"] == null || Request.Params["page"].ToString().Equals(""))
PageCurrent = 1;
else
PageCurrent=int.Parse(Request.Params["page"].ToString());
this.getPage(out TotalPage, out RowsCount, PageSize, PageCurrent);
}
}
//调用存储过程的函数
private void getPage(out int totalPage, out int rowsCount, int pageSize, int currentPage)
{
SqlParameter[] parameters = {
new SqlParameter("@TotalPage", SqlDbType.Int,4),
new SqlParameter("@RowsCount", SqlDbType.Int,4),
new SqlParameter("@PageSize", SqlDbType.Int,4),
new SqlParameter("@CurrentPage", SqlDbType.Int,4),
new SqlParameter("@SelectFields", SqlDbType.NVarChar,700),
new SqlParameter("@IdField",SqlDbType.NVarChar,50),
new SqlParameter("@OrderField", SqlDbType.NVarChar,200),
new SqlParameter("@OrderType", SqlDbType.NVarChar,2),
new SqlParameter("@TableName", SqlDbType.NVarChar,300),
new SqlParameter("@strWhere", SqlDbType.NVarChar,300),
};
parameters[0].Direction = ParameterDirection.Output;
parameters[1].Direction = ParameterDirection.Output;
parameters[2].Value = pageSize;
parameters[3].Value = currentPage;
parameters[4].Value = "a.RLId,a.companyName,a.webSite,a.isRL,a.ordernum,a.isrl,a.userid";
parameters[5].Value = "a.RLId";
parameters[6].Value = " a.isrl asc , a.orderNum ";
parameters[7].Value = "1";
parameters[8].Value = "qiYeRenling a";
parameters[9].Value = "1=1";//
DataSet ds = Wm23Abc.DBUtility.DbHelperSQL.RunProcedure("getRecordByPage", parameters, "dt");
dt = ds.Tables[0];
totalPage = int.Parse(parameters[0].Value.ToString());
rowsCount = int.Parse(parameters[1].Value.ToString());
}
上一篇: Java 详解垃圾回收与对象生命周期
下一篇: mysql 远程连接数据库的方法集合