///
/// 獲得分頁操作sql語句(對於排序的字段必須建立索引)
///
/// 操作表名
/// 操作索引欄位名稱
/// 當前頁
/// 每頁顯示記錄數
/// 返回字段集合,中間用逗號格開。返回全部用「*」
/// 排序方式,0公升序,1為降序
/// 檢索的條件語句,不需要再加where要害字
///
public static string constructsplitsql(string tblname,
string fldname,
int pageindex,
int pagesize,
string rtnfields,
int ordertype,
string strwhere)
// 公升序操作
if( ordertype == 0 )
else }
// 降序操作
else if( ordertype == 1 )
else }
else // 異常處理
return strsql;
} 呼叫**:cs檔案的,參考。。
dataprovider dp = null;
user.datatype = "sqlclient";
user.connectionstring = "server=(local); uid=sa; pwd=1016; database=skyboard";
dp = user.instancedataprovider();
string strcmd = "select count(id) from [address]";
int totalrecord = 1198954;
int pagesize = 20;
int pageindex = (request.querystring["page"] == null) ? 1 : int.parse(request.querystring["page"]);
int pagenum = 0;
if(totalrecord % pagesize == 0)
else
//strcmd = string.format(seaskyer.fso.fobject.readfile(@"e://a.txt"), pagesize * (pageindex - 1) + 1);
strcmd = seaskyer.strings.function.constructsplitsql("address", "id", pageindex, pagesize, "*", 1, "");
response.write(strcmd);
datatable dt = dp.datatablesql(strcmd);
response.write("共有" + totalrecord + ", " + user.splitpages("test.aspx?", pageindex, pagenum, totalrecord ));
datagrid1.datasource = dt.defaultview;
datagrid1.databind();
dt.clear();
dt.dispose();
高效率的分頁儲存過程
create procedure prorobin pagesize int,pageindex int,docount bit as set nocount on if docount 1 select count wzxxbm from ybfld else begin declare inde...
sqlserver分頁的三種實現 非儲存過程
yx new stu表名 gkksh為主鍵 每頁條數10 當前取第二頁 select top 10 from yx new stu where gkksh not in select top 10 gkksh from yx new stu order by gkksh asc order by g...
改進的效率較高的sql2000分頁儲存過程
create procedure dbo test student add the parameters for the stored procedure here id nvarchar 20 學生編號 startrowindex int,起始頁 從0開始 maximumrows int 最大行 ...