| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 331 人关注过本帖
标题:[求助]分页问题,寻求高手解答
取消只看楼主 加入收藏
xunuosangyu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-4-6
收藏
 问题点数:0 回复次数:0 
[求助]分页问题,寻求高手解答
点下一页“Next”的时候很久才出第二页,或超时,大部分情况下是超时的,下面是代码

<!--#include file ="datalink.asp"-->
<!--#include file ="class.asp"-->
<%if not page.IsLogin() then Response.Redirect "default.asp"%>
<html>
<head>
<%

if request("type")<>"" then itype=request("type") else itype="1"
strTable = "供应商表"
strWhere = "where 已删除=0 and 语言='英文' "

'搜索
strRequest = trim(page.requestStr("搜索"))
if strRequest<>"" then
strWhere = strWhere + " and (企业名称 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 省份 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 城市 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 所属行业 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 所属协会 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 通讯地址 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 网址 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 企业性质 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 法人代表 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 成立日期 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 注册资金 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 年销售额 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 员工总人数 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 技术人员 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 管理人员 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 管理人员 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 厂房面积 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 主要产品 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 产能 like '%" + strRequest + "%'"

strWhere = strWhere + " OR 主要客户 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 生产工艺 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 生产设备 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 原材料 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 出口产品 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 出口额 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 质量认证 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 环境认证 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 企业优势 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 企业战略 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 生产加工 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 类型 like '%" + strRequest + "%'"
strWhere = strWhere + " OR 录入人员 like '%" + strRequest + "%')"
end if

strRequest1 = trim(page.requestStr("province"))
if strRequest1<>"" then
strWhere = strWhere + " and (省份 like '%" + strRequest1 + "%')"
end if

strRequest2 = trim(page.requestStr("city"))
if strRequest2<>"" then
strWhere = strWhere + " and (城市 like '%" + strRequest2 + "%')"
end if

strRequest3 = trim(page.requestStr("所属行业"))
if strRequest3<>"" then
strWhere = strWhere + " and (所属行业 like '%" + strRequest3 + "%')"
end if

strRequest5 = trim(page.requestStr("产品名称"))
if strRequest5<>"" then
strWhere = strWhere + " and (主要产品 like '%" + strRequest5 + "%')"
end if

strRequest6 = trim(page.requestStr("工艺"))
if strRequest6<>"" then
strWhere = strWhere + " and (生产工艺 like '%" + strRequest6 + "%')"
end if

strRequest7 = trim(page.requestStr("材质"))
if strRequest7<>"" then
strWhere = strWhere + " and (原材料 like '%" + strRequest7 + "%')"
end if

strSearchId = trim(request("SearchId"))
if strSearchId<>"" then
strWhere = strWhere + " and (Id like '%" + strSearchId + "%')"
end if

'翻页
strOrder = "ORDER BY ID"
strSql="SELECT count(id) as iCou FROM " + strTable + " " + strWhere

rsCou = conn.execute(strSql)
iTotal=rsCou("iCou")

iOnePage=10
iTotalPage=fix((iTotal-1)/iOnePage)+1

if request("page")<>"" then rePage=cint(request("page")) else repage=1
if rePage<=0 then rePage=1
if rePage>iTotalPage then rePage=iTotalPage

Set rs = Server.CreateObject("ADODB.Recordset")
if rePage=1 then
strSQL = "select top " + cstr(iOnePage) + " * from " + strTable + " " + strWhere + " " + strOrder
else
strSQL = "select top " + cstr(iOnePage) + " * from " + strTable + " " + strWhere + " and id not in (select top " + cstr((rePage-1) * iOnePage) + " id from " + strTable + " " + + strWhere + " " + strOrder + ") " + strOrder
end if


delid=request("delid")
if delid<>"" then
response.write delid
strSql="update 供应商表 set 已删除='1' where id in ("+delid+")"
conn.execute(strSql)
if strRequest<>"" then
strUrl="Supplist.asp?type="+request("type")+"&page="+cstr(rePage)+"&搜索="+strRequest
else
strUrl="Supplist.asp?type="+request("type")+"&page="+cstr(rePage)
end if
response.Redirect(strUrl)
end if
%>
<style>
<!--
table { font-size: 12px; font-family: 宋体 }
.p1 { font-size: 15px; font-family: 宋体 }
.p2 { font-size: 12px; font-family: 宋体 }
a { text-decoration: none }
a:hover { color: #ff0000 }
-->
</style>
<title>系统维护</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../../../style.css" type="text/css">
<script>
function del1() //用于判断记录有没有选中的函数
{
var flag=true;
var temp="";
var tmp;
if((document.form1.del.length+"")=="undefined") {tmp=1}else{tmp=document.form1.del.length}
if (tmp==1){
if (document.form1.del.checked){
flag=false;
temp=document.form1.del.value
}
}else{
for (i=0;i<document.form1.del.length;i++) {
if (document.form1.del[i].checked){
if (temp==""){
flag=false;
temp=document.form1.del[i].value
}else{
flag=false;
temp = temp +","+ document.form1.del[i].value
}
}
}
}
if (flag){ alert("对不起,你还没有选择!")}
else{ //name=document.form1.name.value
//alert(name)
if (confirm("确实要删除?"+temp)){
window.location="Supplist.asp?delid="+temp+"&page="+ViewPage.value+'&type='+<%=itype%>+'&搜索='+'<%=strRequest%>';
}
}
return !flag;
}

function show1() //用于判断记录有没有选中的函数
{
var flag=true;
var temp="";
var tmp;
if((document.form1.show.length+"")=="undefined") {tmp=1}else{tmp=document.form1.show.length}
if (tmp==1){
if (document.form1.show.checked){
flag=false;
temp=document.form1.show.value
}
}else{
for (i=0;i<document.form1.show.length;i++) {
if (document.form1.show[i].checked){
if (temp==""){
flag=false;
temp=document.form1.show[i].value
}else{
flag=false;
temp = temp +","+ document.form1.show[i].value
}
}
}
}
if (flag){ alert("对不起,你还没有选择!")}
else{ // name=document.form1.name.value
//alert(name)
//if (confirm("确实要删除?")){
window.location="Supplist.asp?delid="+temp+"&page="+ViewPage.value+'&type='+<%=itype%>+'&搜索='+'<%=strRequest%>';
//}
}
return !flag;
}
</script>

<style type="text/css">
<!--
.STYLE1 {color: #000000}
.STYLE5 {font-family: "Times New Roman", Times, serif; font-size: 14px; color: #000000; }
-->
</style>
</head>

<body bgcolor="#EEEEEE" text="#000000" topmargin="0" leftmargin="0" background="images/dian.gif">
<%rs.Open strSql, conn, 1, 1%>
<!--#include file="page_top.asp"-->
<table border="0" width="700" cellspacing="0" cellpadding="10" bgcolor="#FFFFFF" align="center" style="border-left: 1 solid #808080; border-right: 1 solid #808080; border-bottom: 0 solid #808080">

<tr>
<td width="100%" style="border: 0 solid #808080" bgcolor="#eeeeee">
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="100%">
<table width="100%" height="263" border="0" cellpadding="5" cellspacing="0">
<tr>
<td width="100%" style="border-bottom: 1 solid #FFFFFF">
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="48%"><font color="#3A3A3A"> <img border="0" src="images/B.gif" width="15" height="13">
<strong> List of Enterprises</strong></font></td>
<td width="52%" align="right">[<a href="SuppEdit.asp" target="_self">Register</a>][<a href="Supplist.asp">Refresh</a>] </td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="form2" method="post" action="">
<tr>
<td colspan="2" bgcolor="#F7F7F7">
<p><br>

Province
<select name="province" onChange="javascript:sprice(form2.city,this.value)">
<option value="" selected>None</option>
</select>
City
<select name="city">
<option value="" selected>None</option>
</select>
Industry Sector
<select name="所属行业" class="p9" id="所属行业">
<option value="" selected>None</option>
<option value="Automobile">Automobile</option>
<option value="Machinery">Machinery</option>
<option value="Metallurgy">Metallurgy</option>
<option value="Instrument" >Instrument</option>
<option value="Electronic">Electronic</option>
<option value="Food">Food</option>
<option value="Pharmaceutical">Pharmaceutical</option>
<option value="Chemical">Chemical</option>
<option value="Textile">Textile</option>
<option value="Construction">Construction</option>
<option value="Plastic and Rubber">Plastic and Rubber</option>
<option value="Aerospace">Aerospace</option>
<option value="Shipbuilding">Shipbuilding</option>
<option value="Metal Processing">Metal Processing</option>
<option value="Consumer goods">Consumer goods</option>
<option value="Paper and Wood pulp">Paper and Wood pulp</option>
</select>
</p>
<p>Key words:
<INPUT name="搜索" id="搜索" value="<%=request("搜索")%>" size=12
maxLength=16>
<input name="imageField" type="image" src="images/search.gif" width="50" height="17" border="0">
&nbsp;</p>
</td>
</tr>
</form>
<tr>
<td width="237"><b>Total <%=iTotal%> Results</b></td>
<td width="421" align="right"><%=rePage%>/<%=iTotalPage%> Page items<%=iOnePage%>/page [<a href="#" onClick="form1.action='Supplist.asp?page=<%=rePage-1%>&搜索=<%=strRequest%>';form1.submit();">Previous</a>|<a href="#" onClick="form1.action='Supplist.asp?page=<%=rePage+1%>';form1.submit();">Next</a>]
<input name="ViewPage" type="text" style="text-align: right" value="<%=repage%>" size="2">
Page <a href="#" onClick="form1.action='Supplist.asp?page='+ViewPage.value+'&搜索=<%=strRequest%>';form1.submit();">Scan</a></td>
</tr>
</table>

<table border="0" width="100%" cellspacing="0" cellpadding="2">
<form name="form1" method="post" action="">

<tr>
<td colspan="2" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE"><font color="#FFFFFF"> Company Name</font></td>
<td width="74" align="center" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE"><font color="#FFFFFF">Province</font></td>
<td width="76" align="center" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE"><font color="#FFFFFF">City</font></td>
<td width="56" align="center" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE"><font color="#FFFFFF">Industry Sector</font></td>
<td width="67" align="center" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE"><font color="#FFFFFF">Registered Time</font></td>
<td align="center" bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE">&nbsp;</td>
<td bgcolor="#557BAF" style="border-right: 1 solid #EEEEEE" align="center"><input name="button" type="button" onClick="del1(this.form,<%= rs.recordcount%>,<%=itype%>)" value='Delete'></td>
</tr>

<%
dim j:j=rs.RecordCount
for i=1 to j
%>

<tr>
<td width="8" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE">&nbsp;</td>
<td width="215" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="SuppInfo.asp?id=<%=rs("id")%>" target="_blank"><%=rs("企业名称")%></a></td>
<td align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="SuppInfo.asp?id=<%=rs("id")%>" target="_blank"><%=rs("省份")%></a></td>
<td align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="SuppInfo.asp?id=<%=rs("id")%>" target="_blank"><%=rs("城市")%></a></td>
<td align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="SuppInfo.asp?id=<%=rs("id")%>" target="_blank"><%=rs("所属行业")%></a></td>
<td align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="SuppInfo.asp?id=<%=rs("id")%>" target="_blank"><%=rs("录入日期")%></a></td>

<td width="71" align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><a href="Suppedit.asp?id=<%=rs("ID")%>">Edit</a> <a href="Contlist.asp?QyId=<%=rs("id")%>">Contact</a></td>
<td width="59" align="center" bgcolor="#F7F7F7" style="border-right: 1 solid #EEEEEE; border-top: 3 solid #EEEEEE"><input type="checkbox" name="del" value="<%=cstr(rs("id"))%>" ></td>
</tr>

<%
rs.movenext
next
rs.close
%>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF"><p>&nbsp;</p>
<p><strong>Industrial Sectors: </strong></p>
<p><br>
<a href="supplist_type.asp?type=Automobile"><u>Automobile</u></a>  <a href="supplist_type.asp?type=Machinery"><u>Machinery</u></a>  <a href="supplist_type.asp?type=Food"><u>Food</u></a>  <a href="supplist_type.asp?type=Instrument"><u>Instrument</u></a>  <a href="supplist_type.asp?type=Aerospace"><u>Aerospace</u></a>  <a href="supplist_type.asp?type=Shipbuilding"><u>Shipbuilding</u></a> </p>
<p><br>
<a href="supplist_type.asp?type=Metallurgy"><u>Metallurgy</u></a>  <a href="supplist_type.asp?type=Metal Processing"><u>Metal Processing</u></a>  <a href="supplist_type.asp?type=Chemical"><u>Chemical</u></a>  <a href="supplist_type.asp?type=Textile"><u>Textile</u></a>  <a href="supplist_type.asp?type=Construction"><u>Construction</u></a></p>
<p><br>
<a href="supplist_type.asp?type=Plastic"><u>Plastic</u></a>  <a href="supplist_type.asp?type=Pharmaceutical"><u>Pharmaceutical</u></a>  <a href="supplist_type.asp?type=Consumer goods"><u>Consumer goods</u></a>  <a href="supplist_type.asp?type=Electronic"><u>Electronic</u></a></p>
<p><br>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>

<!--#include file="page_bottom.asp"-->
<!--#include file ="page_pr.asp"-->
</body>

</html>

[此贴子已经被作者于2007-4-6 14:51:40编辑过]

搜索更多相关主题的帖子: 解答 
2007-04-06 14:43
快速回复:[求助]分页问题,寻求高手解答
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042356 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved