'不使用Rs.AbsolutePage方法的分页函数 '可参考我的Blog中:ASP构造大数据量的分页SQL语句。 Function GetPageSQL(tblName,fldName,fldList,PageSize,PageIndex,OrderType,strWhere) Dim strTemp,strSQL,strOrder
'根据排序方式生成相关代码(缺省降序) if OrderType=1 then strTemp=">(select max([" & fldName & "])" strOrder=" order by [" & fldName & "] asc" else strTemp="<(select min([" & fldName & "])" strOrder=" order by [" & fldName & "] desc" end if '若是第1页则无须复杂的语句 if PageIndex=1 then strTemp="" if strWhere<>"" then strTmp = " where " + strWhere end if strSQL = "select top " & PageSize & fldList & " from [" & tblName & "]" & strTmp & strOrder else '若不是第1页,构造SQL语句 strSQL="select top " & PageSize & fldList & " from [" & tblName & "] where [" & fldName & "]" & strTemp & _ " from (select top " & (PageIndex-1)*PageSize & " [" & fldName & "] from [" & tblName & "]" if strWhere<>"" then strSQL=strSQL & " where " & strWhere end if strSQL=strSQL & strOrder & ") as tblTemp)" if strWhere<>"" then strSQL=strSQL & " And " & strWhere end if strSQL=strSQL & strOrder end if GetPageSQL=strSQL '返回SQL语句 End Function
我觉得可以改为这样,不知老大意下如何? function show(table,sql,size,page,fname) page=request.QueryString("page") if page="" then page=1 if page=1 then sql="select top "&size&" * from "&table&" " else sql="select top "&size&" * from "&table&" where("&fname&" not in (select top "&size*(page-1)&" "&fname&" from "&table&"))" end if show=sql end function %>[此贴子已经被作者于2005-4-18 10:41:43编辑过]
我很菜,但我很努力!