WEB开发网
开发学院数据库MSSQL Server 利用Top n实现的分页存储过程 阅读

利用Top n实现的分页存储过程

 2009-11-13 00:00:00 来源:WEB开发网   
核心提示: 使用企业库调用该存储过程的代码示例:Databasedb=DatabaseFactory.CreateDatabase();DbCommandcmd=db.GetStoredProcCommand("CommonPager");db.AddInParameter(cmd,&q

使用企业库调用该存储过程的代码示例:

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);

上一页  1 2 

Tags:利用 Top 实现

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接