利用Top n实现的分页存储过程
2009-11-13 00:00:00 来源:WEB开发网使用企业库调用该存储过程的代码示例:
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand("CommonPager");
db.AddInParameter(cmd, "strTableName", DbType.String, "UserTable");
db.AddInParameter(cmd, "strKeyField", DbType.String, "UniqueID");
db.AddInParameter(cmd, "intPageNumber", DbType.Int32, 2);
db.AddInParameter(cmd, "intPageSize", DbType.Int32, 4);
db.AddInParameter(cmd, "strShowFields", DbType.String, "UniqueID,Name,Age,Sex");
db.AddInParameter(cmd, "strWhereFilter", DbType.String, "");
db.AddInParameter(cmd, "strOrderFields", DbType.String, "UniqueID ASC");
db.AddOutParameter(cmd, "intPageCount", DbType.Int32, 0);
DataSet ds = db.ExecuteDataSet(cmd);
int pageCount = Convert.ToInt32(db.GetParameterValue(cmd, "intPageCount"));
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
Response.Write(pageCount);
更多精彩
赞助商链接